Arduino Uno Spaceship interface project

SAMSUNGToday I am starting a new project called Arduino Project. The actual project is called “spaceship interface” and in this project I will be using arduino board(look like more board from pc) and bread board(white). in addition component are 1 green and 2 red led’s, 4 resistors, switch (button) and jumper wires. I will be building a circuit and there will be video to show the arduino code interacting with the arduino board.

SAMSUNGSAMSUNGSAMSUNG

The first in the arduino book

The one red LED suppose light up on breadboard automatically but I had to unplug usb and troubleshoot. The middle picture has three leds 2 red and 1 green. I put the resistors in the wrong way on breadboard.the last picture show the right way when the code is upload to the board the red led is automatically turn on then when button is press the signal go to green then back to red and it going until release the button.

SAMSUNGSAMSUNGSAMSUNG

int switchState=0;

void setup(){
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(2,INPUT);
}

void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, HIGH); //green LED
digitalWrite(4, LOW); //red LED
digitalWrite(5, LOW); //red LED
}
else { //the button proceed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(250); //wait for quarter second
// toogle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250); //wait for quarter second
}

} // go back to the beginning of the loop

revise code

this program keep the middle red Led light on and only light up red and green on turn on when button is press.

SAMSUNG

int switchState=0;

void setup(){

pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(2,INPUT);
}

void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, LOW); //green LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, LOW); //red LED
}
else { //the button proceed
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);

delay(255); //wait for quarter second
// toogle the LEDs
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(300); //wait for quarter second
}

} // go back to the beginning of the loop

another revise code

When button is press the midddle red light led goes off for a second

SAMSUNG

int switchState=0;

void setup(){
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(2,INPUT);
}

void loop(){
switchState = digitalRead(2);
//if switchState is LOW. turn the green LED on and turn red LED off.
if (switchState == LOW) { //the button is not pressed
digitalWrite(3, HIGH); //green LED
digitalWrite(4, HIGH); //red LED
digitalWrite(5, LOW); //red LED
}
else { //the button proceed
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);

delay(1255); //wait for quarter second
// toogle the LEDs
digitalWrite(4, LOW);
digitalWrite(5, LOW);
delay(2000); //wait for quarter second
}

} // go back to the beginning of the loop

 

Advertisements

One comment

  1. D · October 16, 2014

    An unboxing video??? YEEEEEESSSS! Extra points just for that! LOL!
    Excellent job on this post and project. Ready for an in-class demo?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

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