Basic Arduino Toggle Switch

Published: 09 April 2020
on channel: Mr. Spooner
11,386
69

Basic Arduino slideswitch as a toggle demo in TinkerCAD with two LEDs.

//-----Code-----

int yledPin = 13;
int gledPin = 9;

int switchYPin = 6;
int switchGPin = 2;

void setup()
{
pinMode(yledPin, OUTPUT);
pinMode(switchYPin, INPUT);

pinMode(gledPin, OUTPUT);
pinMode(switchGPin, INPUT);

Serial.begin(9600);
}

void loop()
{
if (digitalRead(switchYPin)){
digitalWrite(yledPin, HIGH);
digitalWrite(gledPin, LOW);
}
if (digitalRead(switchGPin)){
digitalWrite(yledPin, LOW);
digitalWrite(gledPin, HIGH);
}

}


On this page of the site you can watch the video online Basic Arduino Toggle Switch with a duration of hours minute second in good quality, which was uploaded by the user Mr. Spooner 09 April 2020, share the link with friends and acquaintances, this video has already been watched 11,386 times on youtube and it was liked by 69 viewers. Enjoy your viewing!