Arduino Board and PIR Motion Sensor Control AC Lamp



Introduction: Arduino Board and PIR Motion Sensor Control AC Lamp

About: revolutionary device designed to control AC Loads working on 110V/220V allowing to control High voltage AC loads using Microcontrollers Like AVR,PIC,STM32 or Electronics platforms like arduino,Raspberry pi,b...

This is a short tutorial to see how we can Control AC voltage Application ( AC Lamp in our case) depends on a motion sensor.

The biggest problem we face in controlling any AC voltage application is:


2)easy and reliable.method for everyone

The relay is a common way to control AC voltage with many disadvantages: unprotected pins may cause an electrical shock hazard.need someone with full understand how to connect the wires and where,any mistake is unforgivable,so it's not for everyone to do.Cut many wires,prepare AC plug in and AC socket to connect everything together which make the connection more complicated and dangerous.instead of relay, we will use a unique device called (Sugar) this device designed to control AC voltage application using any development platform(Arduino,Raspberry pi, IOT boards,etc) and no naked wire required to connect the AC load or even the data cable.

Step 1: Components

We need just a few components to do this experiment:

  1. Arduino Board(Uno,Mega,mini..etc)
  2. PIR Motion sensor
  3. Sugar device.
  4. RJ12 Cable.
  5. RJ12 breakout
  6. .AC Lamp+AC lamp socket
  7. AC C14 Power cord
  8. .Breadboard
  9. Jumpers (Male-Male).

this is what you need so move to connection

Step 2: Schematic and Connection

Here is the schematic for controlling circuit.

For the power circuit , no need to cut a wire ,no screw driver,all you need is connect:

  1. Connect the AC Lamp to sugar.
  2. Connect Sugar to AC power supply using C14 Cord.
  3. Connect RJ12 cable between Sugar device and arduino.

That's it !

Step 3: You Love Sugar Device ? We Need Your Help

Sugar is a startup project , designed and Manufactured the Prototypes in Taipei - Taiwan and Now sugar need your help to become a real product in the market and bring a simple tools to control AC voltage.

Sugar comes in 2 different type :

  • Sugar300 : can Handle Up to 300 W
  • Sugar1000 : can Handle Up to 1000 W

and both type support AC output voltage control "For Dimmer applications" Hope you support us and become our backer Now on Indiegogo Campaign, we updated the artical ,you can visitour campaign page Here.

Keep in touch with us on Facebook ,Twitter , Google+ , Instagram , Youtube official accounts.

Visit Ourwebsite to see all features and tutorial and see the story behind sugar

Step 4: Code and Test Video

arduino Code is very simple:

const int PIRpin=2;
const int Sugarpin=9; const int LEDpin=13; int Brightness = 12; void setup() { pinMode(PIRpin,INPUT); pinMode(Sugarpin,OUTPUT); pinMode(LEDpin,OUTPUT); analogWrite(Sugarpin,Brightness); }

void loop() { boolean PIR=digitalRead(PIRpin); delay(50); if(PIR==true) { Brightness=64; analogWrite(Sugarpin,Brightness); digitalWrite(LEDpin,HIGH); delay(1000); while(PIR==true) { PIR=digitalRead(PIRpin); delay(50); } Brightness=12; analogWrite(Sugarpin,Brightness); digitalWrite(LEDpin,LOW); } }

just to illustrate some parts of the code:

if we want to turn on AC lamp connected to sugar we write:



if we want to turn off AC lamp connected to sugar we write:



and the video shows how the circuit works:

Be the First to Share


    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020