While working on the regular projects in office, I have joined SAP Ariba IOT Group where we try out few things which can solve some problem which could be really helpful.
I am also trying to use Raspberry Pi, Arduino and other platforms.
Recently i have tried to build a smart light, which I want to fix it to my study table now. :-)
Circuit:
I have picked the circuit from internet which explains about the connectivity of different components.
Circuit Diagram |
Demo Video:
Here is a short video about it.
Hardware Components:
Arduino Uno | 1 |
Relay Module | 1 |
PIR Motion Detector Sensor Module | 1 |
Connectors/Jumper Wires | 6 |
Power Cable | 1 |
Power adaptor for Arduino Uno | 1 |
Light | 1 |
Software Components:
Arduino IDE | 1 |
![]() |
Smart Light Code |
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pirSensor = 6; | |
int relayInput = 8; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(pirSensor, INPUT); | |
pinMode(relayInput, OUTPUT); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
int sensorValue = digitalRead(pirSensor); | |
if (sensorValue == 1) { | |
digitalWrite(relayInput, LOW); | |
delay(5000); | |
digitalWrite(relayInput, HIGH); | |
} |
Troubleshoot:
While uploading the code there was an issue with PORT( /dev/ttyACM on ubuntu) read/write permission
Following commands helped:
deepak@deepak-B570:$ ls -l /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 May 12 19:21 /dev/ttyACM0
deepak@deepak-B570:$ ls -l /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 May 12 19:21 /dev/ttyACM0
deepak@deepak-B570:$ sudo chmod a+rw /dev/ttyACM0
[sudo] password for deepak: ********