In this tutorial, we will integrate IR sensors with Surilli GSM to control the operation of the street lights. These sensors will sense the position of the vehicle and give its signal to Arduino and as a result, it will turn ON the LEDs. If this idea is implemented in any city, it will be helpful in saving enough electricity and money.
What Is an IR Sensor?This IR proximity sensor is a multipurpose infrared sensor which can be used for obstacle sensing, color detection, fire detection, line sensing etc and also as an encoder sensor. The sensor provides a digital output. In this case, the sensor outputs a logic one (+5V) at the digital output when it detects black line in front of the sensor and a logic zero (0V), when there is white line in front of the sensor. An onboard LED is used to indicate the presence of black and white. This digital output is directly connected to Surilli GSM.
Components Required- Surilli GSM.
- Connecting wires.
- 4 LEDs.
- 4 IR sensors.
Connections Between Surilli GSM, IR Sensors, and LEDs:
IR1 (PIN D0) ---> SURILLI GSM(PIN 5)
IR1(PIN GND) ---> SURILLI GSM(PIN GND)
IR1(PIN VCC) ---> SURILLI GSM(PIN USB)
IR2(PIN DO) ---> SURILLI GSM(PIN 11)
IR2(PIN GND) ---> SURILLI GSM(PIN GND)
IR2(PIN VCC) ---> SURILLI GSM(PIN USB)
IR3(PIN DO) ---> SURILLI GSM(PIN 6)
IR3(PIN GND) ---> SURILLI GSM(PIN GND)
IR3(PIN VCC) ---> SURILLI GSM(PIN USB)
IR4(PIN DO) ---> SURILLI GSM(PIN 9)
IR4(PIN GND) ---> SURILLI GSM(PIN GND)
IR4(PIN VCC) ---> SURILLI GSM(PIN USB)
LED 1 (+ PIN) ---> SURILLI GSM(PIN 10)
LED 1 (- PIN) ---> SURILLI GSM(PIN GND)
LED 2 (+ PIN) ---> SURILLI GSM(PIN 12)
LED 2 (- PIN) ---> SURILLI GSM(PIN GND)
LED 3 (+ PIN) ---> SURILLI GSM(PIN 0)
LED 3 (- PIN) ---> SURILLI GSM(PIN GND)
LED 4 (+ PIN) ---> SURILLI GSM(PIN 1)
LED 4 (- PIN) ---> SURILLI GSM(PIN GND)
STEP 1: Set Up Arduino IDE for SurilliMake sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
STEP 2: The CircuitryThe circuitry is very simple. Follow the figure below to set up your hardware.
STEP 3: Upload and Burn Code Onto Surilli
Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.After it is uploaded, the IR sensor will start working and the LEDs will turn OFF when any vehicle passes through that IR sensor.
Arduino Code:int ir1=5;
int ir2=6;
int ir3=9;
int ir4=10;
int led1=11;
int led2=12;
int led3=0;
int led4=1;
int proxy1=0;
int proxy2=0;
int proxy3=0;
int proxy4=0;
void setup()
{
pinMode(ir1,INPUT);
pinMode(ir2,INPUT);
pinMode(ir3,INPUT);
pinMode(ir4,INPUT);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
}
void loop(){
proxy1=digitalRead(ir1);
proxy2=digitalRead(ir2);
proxy3=digitalRead(ir3);
proxy4=digitalRead(ir4);
if(proxy1==HIGH)
{
digitalWrite(11,HIGH);
}
else
{
digitalWrite(11,LOW);
}
if(proxy2==HIGH)
{
digitalWrite(12,HIGH);
}
else
{
digitalWrite(12,LOW);
}
if(proxy3==HIGH)
{
digitalWrite(0,HIGH);
}
else
{
digitalWrite(0,LOW);
}
if(proxy4==HIGH)
{
digitalWrite(1,HIGH);
}
else
{
digitalWrite(1,LOW);
}
}
Play with the program to see how it reacts to different values and logic. This will develop your understanding about IR sensor so you can use them in your practical applications.
If you make something funny and interesting do share it with our community.
That’s all for now. If you have any queries, visit our website surilli.io or contact our support. Stay connected with Surilli family for more amazing stuff. :-)
Comments
Please log in or sign up to comment.