Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
laurenkoi
Published

Arduino Project 2

Learning to control electricity with lights and switches. This project is my first programming time for Arduino.

BeginnerShowcase (no instructions)1 hour36
Arduino Project 2

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Through Hole Resistor, 10 kohm
Through Hole Resistor, 10 kohm
×1

Story

Read more

Schematics

Fritzing

Schematics

Video

Code

Spaceship Interface Code

Arduino
Press the button, and the countdown of lights start.
int switchState = 0; 
void setup(){  
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT); 
  pinMode(5, OUTPUT);
  pinMode(2, INPUT);
}
void loop() { 
  switchState=digitalRead(2); 
  if (switchState == LOW) { 
    digitalWrite(3, HIGH); 
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }
  else { 
    digitalWrite(3, LOW);
    digitalWrite(4, LOW); 
    digitalWrite(5, HIGH);
    delay(250); 
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    delay(250);
  }
}

Credits

laurenkoi
13 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.