Arduino Tutorial 14- Using a Pushbutton as a Toggle Switch

preview_player
Показать описание
Let's use a pushbutton as a toggle switch!

--------------------------------------------------------------------
► Get Your First Arduino Starter Kit 👇:
--------------------------------------------------------------------

FOLLOW ME:
--------------------------------------------------------------------

► All content by Enjoy Mechatronics is 100% free. I believe that education should be freely available to everyone.
Рекомендации по теме
Комментарии
Автор

Your explanation and demonstration was very clear. When I wired up the LED and switch as you showed and entered the code it worked first time. I liked the way you entered code and the altered it as you went along. It really helped my understanding of developing code as one proceeds with the design.

kevindegoede
Автор

epic video i learn every time i follow your tutorial one more step towards my steper motoer control code with push button and limit switch controller :-) ty

johngardiner
Автор

Good vidio. This video explains step by step. Very understanding

nyaa
Автор

Hi! Is there a way to do the opposite? use a physical toggle switch to create a push button action?
I am a total newbie when it comes to Arduino. thanks a lot

mathieubannwarth
Автор

Why you wrote oldValue = newValue at last

brothersinformation
Автор

int pinbo = 2;
int state;
int oldstate = 1;
int led = 8;
class String ledstate = "OFF";

void setup(){
pinMode(pinbo, INPUT_PULLUP);
pinMode(led, OUTPUT);
}

void loop(){
state = digitalRead(pinbo);
oldstate = state;
if(state == 1 && oldstate == 1){
if(ledstate == "OFF"){
digitalWrite(led, HIGH);
ledstate = "ON";
}
else {
digitalWrite(led, LOW);
ledstate = "OFF";
}
}
delay(1);


}

ThePotatoGLaDos
visit shbcf.ru