File size: 532 Bytes
05ff5dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}