Jump to content


Check out our Community Blogs





- - - - -

Arduino Project 02

Posted by Alcamech, 06 August 2013 · 9007 views

arduino uno project programming code open source circuitry electronics
Well a few days ago, I managed to complete the Arduino project 02 titled "Spaceship interface". This project involved 4 components; a switch, led, 220 ohm resistor, and a 10 kilohm resistor . after wiring up the breadboard and building the circuit I got to (finally) program the arduino xD. Here are the results:

This time its a video :thumbup:

*** I've made a few mistakes in the video and excuse the shakiness and bad quality***





Source Code:
int switchState = 0;
//configures the digital pins
void setup(){
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(2,INPUT);
}

//Checks the voltageo of the digital input and chooses the pin for voltage ( pin 2 )
void loop(){
  switchState = digitalRead(2);
  
  if(switchState == LOW){
    //Button is not pressed 
    
    digitalWrite(3,HIGH); //Green LED 
    digitalWrite(4,LOW); //Red LED 
    digitalWrite(5,LOW); //red LED
  }

else { //the button is pressed
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(5,HIGH);
  
  delay(250); //wait for a quarter second
  //toggle the LEDs
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  delay(250); //wait for a quarter second 
}
} //go back to the beginning of the loop


  • 1



Nice! Keep it going, man!

    • 0

thanks

    • 0

Nice and good 

    • 0

Recent Entries

Recent Comments

My Picture

0 user(s) viewing

0 members, 0 guests, 0 anonymous users

Categories

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download