Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
이하늘gledel임동교
Published © GPL3+

InoLab: Reading a SPDT Switch

This project was made by Innovation Lab at Bongilcheon High School.

BeginnerShowcase (no instructions)30 minutes1,330
InoLab: Reading a SPDT Switch

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Slide Switch
Slide Switch
×1
LED (generic)
LED (generic)
×2
Resistor 221 ohm
Resistor 221 ohm
×2

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

d_J1P1J6DOnb.PNG

Code

Untitled file

Arduino
const int switchPin = 3;
const int led1Pin = 12;
const int led2Pin = 13;
void setup()
{
pinMode(switchPin, INPUT);
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
}
void loop()
{
int switchVal;
switchVal = digitalRead(switchPin);
if (switchVal == HIGH)
{
digitalWrite(led1Pin, HIGH);
delay(500);
digitalWrite(led1Pin, LOW);
delay(500);
}
else
{
digitalWrite(led2Pin, HIGH);
delay(500);
digitalWrite(led2Pin, LOW);
delay(500);
}
}

Credits

이하늘
5 projects • 3 followers
Contact
gledel
100 projects • 116 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"
Contact
임동교
0 projects • 12 followers
Contact

Comments

Please log in or sign up to comment.