Project overview

This is an interactive art installation used for marketing an app called “Blue Plus”, which aims at stimulating people to make positive contributions on climate change problems through their daily activities. This art installation has three main parts.
The first part is the model-making part, which is the iceberg with lights attached on the wall. And audience will race the bicycle to turn on the lights.
The second part is also controlled by the bicycle. The penguin will walked around the bicycle areas to celebrate “someone is saving their home” with sound.
The third part is still not sure whether it can be accomplished by the due date. But we supposed to mimic the iceberg melting abstractly by Processing.

Work Divide

1)Iceberg

Model-making(Kellie & Mei)

Soldering, Arduino code(Kellie)

2) Penguin

Model-making, Soldering, Arduino code (Mei)

Schematic

1_schem

Arduino code (Penguin)

#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#include <NewPing.h>
//#include "kellie.h"


#define TRIGGER_PIN  5
#define ECHO_PIN     8
#define MAX_DISTANCE 300
#define TOO_CLOSE 10
#define DIS_COLLISION 30
#define DRIVE_FORWARD 0
#define TURN_LEFT     1
#define MOTORLEFT_PIN
#define MOTORRIGHT_PIN
#define HIGHSPEED 255
#define LOWSPEED 10
int incoming = Serial.available();
// motors

// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

//int kellie = 0;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

// for Ultra sonic sensor
const int serialPeriod = 250;       // only print to the serial console every 1/4 second
unsigned long timeSerialDelay = 0;

const int loopPeriod = 20;          // a period of 20ms = a frequency of 50Hz
unsigned long timeLoopDelay   = 0;
int motorPinLeft = 10;
int motorPinRight = 9;
int usDistance;

int state = DRIVE_FORWARD;

void initialize() {
  analogWrite(motorPinLeft, HIGHSPEED);
  analogWrite(motorPinRight, HIGHSPEED);
}

void stopCar() {
  unsigned long timeToStop = 1000;
  unsigned long startTime = millis();
  Serial.println("Stopped");
  while ((millis() - startTime) < timeToStop) {
    analogWrite(motorPinLeft, 0);
    analogWrite(motorPinRight, 0);
  }
}

void turn() {
  //Serial.println(usDistance);
  if (usDistance < DIS_COLLISION && usDistance > TOO_CLOSE) {
    turnLeft();
    //state = DRIVE_FORWARD;
  } else {
    goStraight();
  }
}

void turnLeft() {
  musicPlayer.startPlayingFile("laugh.mp3");
  unsigned long timeToTurnLeft = 1200;
  // save the time that we started turning
  unsigned long turnStartTime = millis();
  // stay in this loop until timeToTurnLeft (1.1 seconds) has elapsed
  while ((millis() - turnStartTime) < timeToTurnLeft) {
    analogWrite(motorPinLeft, LOWSPEED);
    analogWrite(motorPinRight, HIGHSPEED);
  }
  musicPlayer.stopPlaying();
}

void goStraight() {
  unsigned long timeToStraight = 1000;
  unsigned long startTime = millis();
  while ((millis() - startTime) < timeToStraight) {
    analogWrite(motorPinLeft, HIGHSPEED);
    analogWrite(motorPinRight, HIGHSPEED);
  }
}



void setup() {
  Serial.begin(9600);
  //Serial1.begin(9600);
  Serial.println("Serial Monitor Connected");
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
    Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
    while (1);
  }
  Serial.println(F("VS1053 found"));

  SD.begin(CARDCS);    // initialise the SD card

  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20, 20);
  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
    Serial.println(F("DREQ pin is not an interrupt pin"));
  Serial.println("s - play Laugh\n b - play Banana \n p - Stop the music \n n - stop the car");
  Serial.println("Initialize the car");
  initialize();
}

void loop() {
  usDistance = sonar.ping_in();
  Serial.println(usDistance);
  if (usDistance <= TOO_CLOSE && usDistance != 0)
    stopCar();
  else
    turn();
    
  if (incoming != 0) {
    char c = Serial.read();
    // if we get an 's' on the serial console, start!
    // kellie = Serial1.parseInt();
    // incoming = Serial.available();

    if (c == 's') {
      if (musicPlayer.stopped())
        musicPlayer.startPlayingFile("laugh.mp3");
    }

    if (c == 'b') {
      if (musicPlayer.stopped())
        musicPlayer.startPlayingFile("banana.mp3");
    }

    // if we get an 'p' on the serial console, stop!
    if (c == 'p') {
      if (!musicPlayer.stopped()) {
        musicPlayer.stopPlaying();
      }
    }
  }
}

 

Parts List

Penguin:
1 Arduino Uno shield
1 Ultra sonic sensor, New ping(Lab)
2 Xbee pro(Lab)
1 Xbee shield(Lab)
1 Xbee explorer(Lab)
1 MP3 shield(Hongru)
1 Micro SD card(Hongru)
2 Motors with 2 wheels(Lab)
1 Support wheel(Lab)
2 Transistors(Lab)
1 Speaker(Lab)
1 USB wire
1 Portable charger
1 piece of black paper(Arch)
1 printing model

penguin

WeChat_1431275091 WeChat_1431275100

Problems(Penguin)

1. Problem to connect Xbee

Solution:

Change as another Xbee explorer.
Using XCTU to configure Xbee.
http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu
https://learn.sparkfun.com/tutorials/xbee-wifi-hookup-guide

2. Don’t know how to let two Arduino sketch work together and use Xbee at the same time.

Trial

Tried to follow some instructions but didn’t finish that.
http://hacknmod.com/hack/how-to-connect-multiple-arduino-microcontrollers-using-i2c/

3. When uploading the sketch, the uploading time is long and there is always error.

Solution:

I thought it might be problem with pins. Then I checked the document. But I found there is nothing wrong with my pins.

Pins I occupied:
13 MP3 Shield
12 MP3 Shield
11 MP3 Shield
10 Motor
9 Motor
8 Ultra sonic distance sensor

7 MP3
6 MP3
5 Ultra sonic distance sensor
4 MP3
3 MP3
2 (null)
1 xbee
0 xbee

When remove the Xbee shield, I can upload easily and Xbee works well. So NEVER EVER upload code with Xbee shield.

4. One motor doesn’t work. And wires are easy to be broken when I tested for many times.

Solution:

I re-soldered my board again and used glue gun to make sure all wires are steady.

The old one:

WeChat_1431244386WeChat_1431244395

The new one:

WeChat_1431244710 WeChat_1431244731 WeChat_1431244829

5. Arduino is heavy. Putting Arduino into the model of Penguin makes it not stable.

Solution:

I made a model inside for making sure everything would be in a box.
WeChat_1431244769

Result

The penguin can work by itself and avoid obstacle in front of it. When it is too close to the obstacle, it will stop working. When it turn, it will laugh. Using Xbee realizes controlling the sound with computer.

Future

What need to be realized is communicating two Arduino boards together.

Comments(0)

Leave a Comment