PIR Motion Sensor for ArLCD Touchscreen Backlight

by Jazzmyn in Circuits > Arduino

2489 Views, 18 Favorites, 0 Comments

PIR Motion Sensor for ArLCD Touchscreen Backlight

IMG_8969.JPG
IMG_8964.JPG


Hi, its Jazz with a new tutorial.  Today we are going to be using a PIR motion sensor to change the brightness of the arLCD screen.  Motion detection is useful for things you don't want on all the time.  For example to save battery life and to turn the screen off when you are not there.  For this project you will need three jumper wires, a breadboard, PIR motion sensor, and an arLCD.

Assembly

IMG_8962.JPG
IMG_8966.JPG
IMG_8968.JPG
The motion sensor has three pins one for signal, VCC for five volts, and ground.  Place the PIR sensor on the board so each pin has its own row.  Put a jumper wire in each row.  Hook up the signal out jumper wire to any digital pin that you want but I used pin three.  Hook up the VCC to five volts and the ground to the ground pin on the Arduino.

Code

Copy and paste the code below into your Arduino IDE

#include

ezLCD3 lcd;

int pirPin = 3;

void setup()
{
  lcd.begin( EZM_BAUD_RATE );
  lcd.cls();
  lcd.picture(40,0,"emh.gif");
  lcd.picture(0,45,"ArdHeart.gif");
  lcd.picture(110,135,"arLogo.gif");
  pinMode(pirPin, INPUT);
}

void loop()
{
  if(digitalRead(pirPin) == HIGH)
  {
    lcd.light(100);
  }
  if(digitalRead(pirPin) == LOW)
  { 
   lcd.light(5);
  }
}