WHAT WE'LL NEED
- ARDUINO BOARD & CABLE
- BREADBOARD
- TACT SWITCH
- LED
- 10K RESISTOR
- JUMPER WIRE
THE CODE SHOULD LOOK LIKE THIS
/* using tact switch to switch an led ON/OFF connected to pin 3
of the arduino...
AUTHOR: ANIEROBI PETER
DATE: 4/23/2014
www.hub360.blogspot.com, www.facebook.com@hub360
*/
int switch =4; // tact switch connected to analog pin 4
int led = 3;// led connected to pin 3
int x;
void setup(){
pinMode(switch,INPUT); //set tact as input
pinMode(led,OUTPUT); //set led as output
}
void loop(){
x= digitalRead(switch); //read to know if switch is detected or not
digitalWrite(led,x); //ON or OFF an LED according to detection
}
TACT SWITCH by hub360 |
we sincerely hope you find this amazing
think...create...repeat
No comments :
Post a Comment