toggleSwitchbuttonSwitch.159 / toggleSwitchbuttonSwitch.159.ino
antitheft159's picture
Upload toggleSwitchbuttonSwitch.159.ino
05ff5dc verified
raw
history blame contribute delete
No virus
532 Bytes
int butPin=2;
int redPin=10;
int br=115200;
int butVal=1;
int butValOld=1;
int LEDstate=0;
int delayT=50;
void setup() {
// put your setup code here, to run once:
Serial.begin(br);
pinMode(redPin,OUTPUT);
pinMode(butPin,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
butVal=digitalRead(butPin);
if (butValOld==0 && butVal==1){
if (LEDstate==0){
digitalWrite(redPin, HIGH);
}
if (LEDstate==1){
digitalWrite(redPin,LOW);
}
LEDstate=!LEDstate;
}
butValOld=butVal;
}