Devices & Components
Arduino Uno Rev3
Tactile Switch, Top Actuated
Jumper wires (generic)
Resistor 10k ohm
Software & Tools
Arduino IDE
Project description
Code
the full code:
arduino
download and use it!
1#define buttonPin 2 2#define ledPin 13 3bool state = 0; 4bool lastRead = 0; 5void setup() { 6 // put your setup code here, to run once: 7Serial.begin(9600); 8pinMode(2,INPUT); 9pinMode(13,OUTPUT); 10} 11void loop() { 12 // put your main code here, to run repeatedly: 13state = digitalRead(2); 14if(state != lastRead) 15{ 16 Serial.println(state); 17digitalWrite(ledPin,state) 18 lastRead = state; 19} 20}
the full code:
arduino
download and use it!
1#define buttonPin 2 2#define ledPin 13 3bool state = 0; 4bool lastRead 5 = 0; 6void setup() { 7 // put your setup code here, to run once: 8Serial.begin(9600); 9pinMode(2,INPUT); 10pinMode(13,OUTPUT); 11} 12void 13 loop() { 14 // put your main code here, to run repeatedly: 15state = digitalRead(2); 16if(state 17 != lastRead) 18{ 19 Serial.println(state); 20digitalWrite(ledPin,state) 21 lastRead 22 = state; 23} 24}
Downloadable files
Schematic:
Schematic:

Schematic:
Schematic:

circuit:
circuit:

Comments
Only logged in users can leave comments