Devices & Components
LED
Button
Alligator Clips
Software & Tools
Arduino IDE
Project description
Code
button_code
arduino
This code will be the only code you will need. This will tell the computer or microcontroller that pinmode 9 is connected to the button and the led is connected to pinmode 3. The microcontroller will constantly be checking if pin 2 is low. If pin 2 is low, pin three goes high.
1void setup() { 2 //button1 3 pinMode(9,INPUT); 4 //led1 5 pinMode(3,OUTPUT); 6} 7 8void loop() { 9 if(digitalRead(2)==LOW){ 10 digitalWrite(3,HIGH); 11 } 12} 13
button_code
arduino
This code will be the only code you will need. This will tell the computer or microcontroller that pinmode 9 is connected to the button and the led is connected to pinmode 3. The microcontroller will constantly be checking if pin 2 is low. If pin 2 is low, pin three goes high.
1void setup() { 2 //button1 3 pinMode(9,INPUT); 4 //led1 5 pinMode(3,OUTPUT); 6} 7 8void 9 loop() { 10 if(digitalRead(2)==LOW){ 11 digitalWrite(3,HIGH); 12 } 13} 14
button_code
arduino
This code will be the only code you will need. This will tell the computer or microcontroller that pinmode 9 is connected to the button and the led is connected to pinmode 3. The microcontroller will constantly be checking if pin 2 is low. If pin 2 is low, pin three goes high.
1void setup() { 2 //button1 3 pinMode(9,INPUT); 4 //led1 5 pinMode(3,OUTPUT); 6} 7 8void loop() { 9 if(digitalRead(2)==LOW){ 10 digitalWrite(3,HIGH); 11 } 12} 13
Comments
Only logged in users can leave comments