Close

Build log 12- boot schematic and code

A project log for Animatronic Iron Man MKIII suit

RFID tags in the gloves control shoulder rockets pods, hip pods, forearm missile, back flaps and wireless helmet.

jeromekeltyjeromekelty 04/27/2014 at 02:250 Comments

Here's the schematic and code for the boots- it's pretty simple. The Sharp IR sensor inputs a value into the Arduino which triggers the Luxeon boot lights and the WaveShield to play an audio file.

A larger version can be seen here.

Here's the code-

// these constants won't change:

int triggerSensor = 1;            // the sensor is connected to analog pin 1
int threshold = 750;              // threshold value to decide when the sensor input triggers
int ledPin = 3;                        // control pin for LED
int soundPin = 2;                   // control pin for sound board

// these variables will change:
int sensorReading = 0;          // variable to store the value read from the sensor pin


void setup() {
Serial.begin(9600);                      // use the serial port
pinMode(ledPin, OUTPUT);         // sets the LED pin as an output
pinMode(soundPin, OUTPUT);    // sets the sound pin as output
digitalWrite(ledPin, LOW);            // turn off LED
digitalWrite(soundPin, LOW);       // turn the sound off

}

void loop() {

// read the sensor and store it in the variable sensorReading:
int val = analogRead(triggerSensor);

// if the sensor reading is greater than the threshold:
if (val >= threshold) {

Serial.println(val);
digitalWrite(soundPin, HIGH);             // turn the sound on
delay(10);                                              // wait ten milliseconds
digitalWrite(soundPin, LOW);              // turn the sound off
digitalWrite(ledPin, HIGH);                  // turn the LED on
delay(2400);                                        // wait two seconds
digitalWrite(ledPin, LOW);                   // turn the LED off
}


}

Discussions