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);
}
}
Watch video Basic Arduino Toggle Switch online without registration, duration hours minute second in high quality. This video was added by user Mr. Spooner 09 April 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 9,772 once and liked it 60 people.