Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // https://www.youtube.com/c/LeventeDaradici/videos
- //
- int StareButon = 0;
- int UltimaStareButon = 0;
- int StareOnOff = 0;
- const int PinButon = 2;
- const int PinLED = 3;
- void setup()
- {
- Serial.begin(9600);
- pinMode(PinButon,INPUT);
- pinMode(PinLED,OUTPUT);
- }
- void loop()
- {
- StareButon = digitalRead(PinButon);
- if (StareButon != UltimaStareButon)
- {
- if (StareButon == HIGH)
- {
- StareOnOff = StareOnOff + 1;
- if (StareOnOff > 1)
- {
- StareOnOff = 0;
- }
- Serial.println(StareOnOff);
- if (StareOnOff == 0)
- {
- digitalWrite(PinLED, LOW);
- }
- if (StareOnOff == 1)
- {
- digitalWrite(PinLED, HIGH);
- }
- }
- }
- delay(5);
- UltimaStareButon = StareButon;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement