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

Automatic Light Switch

This is a device that lets me controll my light switch, by laying down on my bed.

BeginnerFull instructions provided637
Automatic Light Switch

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×13

Story

Read more

Schematics

Automatic Light Switch Schematics

Code

Automatic Light Switch Code

C/C++
#include <Servo.h>

Servo Bottom_Servo;  
Servo Top_Servo;

int pos = 0;
const int Button = 12;
int buttonState = 0;

void setup() {
  Bottom_Servo.attach(9);
  Top_Servo.attach(8);
  pinMode(Button, INPUT);
}

void loop() {
  buttonState = digitalRead(Button);
  if (buttonState == HIGH) {
    Top_Servo.write(0);
    delay(100);
    Bottom_Servo.write(75);
  } else {
    Bottom_Servo.write(0);
    delay(100);
    Top_Servo.write(75);
  }


  
  } 

Credits

nerdstuff6
0 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.