[vc_row][vc_column][vc_column_text]In this project, we will control three different LEDs independently with three different buttons.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Wiring Diagram” tab_id=”1394775422-1-76″][vc_column_text][/vc_column_text][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Arduino Code” tab_id=”1394775422-2-91″][vc_column_text]
int redled = 10; int yellowled = 9; int greenled = 8; int redpin = 7; int yellowpin = 6; int greenpin = 5; int red; int yellow; int green; void setup() { pinMode(redled,OUTPUT); pinMode(yellowled,OUTPUT); pinMode(greenled,OUTPUT); pinMode(redpin,INPUT); pinMode(yellowpin,INPUT); pinMode(greenpin,INPUT); } void loop() { red=digitalRead(redpin); if(red==LOW) { digitalWrite(redled,LOW);} else { digitalWrite(redled,HIGH);} yellow=digitalRead(yellowpin); if(yellow==LOW) { digitalWrite(yellowled,LOW);} else { digitalWrite(yellowled,HIGH);} green=digitalRead(greenpin); if(green==LOW) { digitalWrite(greenled,LOW);} else { digitalWrite(greenled,HIGH);} }
[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.