motion detector+led screen 8×8, KATE

Hi, i decided to make a simple motion detector circuit. And i like text more than smiley faces)

 

Here is my video

 

Here is my code

#include <Wire.h>
#include “Adafruit_LEDBackpack.h”
#include “Adafruit_GFX.h”

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

void setup() {
pinMode(inputPin, INPUT);     // declare sensor as input

Serial.begin(9600);
Serial.println(“8×8 LED Matrix Test”);

matrix.begin(0x70);  // pass in the address
}

void loop() {
val = digitalRead(inputPin);  // read input value
if (val == HIGH) {            // check if the input is HIGH

delay(150);

if (pirState == LOW) {
// we have just turned on
Serial.println(“Motion detected!”);

matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_GREEN);
for (int8_t x=7; x>=-36; x–) {
matrix.clear();
matrix.setCursor(x,0);

matrix.print(“Motion detected!”);
matrix.writeDisplay();
delay(100);
}
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {

delay(300);
if (pirState == HIGH){
// we have just turned of
Serial.println(“Motion ended!”);

  matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_GREEN);
for (int8_t x=7; x>=-36; x–) {
matrix.clear();
matrix.setCursor(x,0);

matrix.print(“No Motion detected!”);
matrix.writeDisplay();
delay(100);
}

// We only want to print on the output change, not state
pirState = LOW;
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s