Homework 06-Chain Reaction 1-Elena Brown, Josiah Song, Arthur Dunne, and Tyler Cook

26 Nov

We setup a system of blinking lights using three arduino boards. We also attempted to add a servo motor to the circuit but couldn’t figure out the code. Here is the code that was used for this assignment.
2013-11-21 20.41.55

01960df84aa4137102dcb2b5a73dcbfe599fd55323_00001
FOR THE MASTER BOARD BLINKING:
int led = 13;

void setup() {
pinMode(led, OUTPUT);
}

void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

TO CONNECT THE OTHER TWO ARDUINO BOARDS TO THE BLINKING SYSTEM:

const int LED = 13;//the master board was set as the output for the other two arduino boards at pin 13

const int BUTTON = 7;//set the input to pin 7

int val = 0;//initial value is zero

int state = 0;

void setup() {

pinMode (LED, OUTPUT);//master board at pin 13 is the output

pinMode (BUTTON, INPUT);

}

void loop () {

val = digitalRead (BUTTON);

if (val==HIGH){

state = 1 – state;

}

if (state==1) {

digitalWrite(LED, HIGH);//turn LED on

} else {

digitalWrite(LED, LOW);//turn LED off

}

}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s