-
PIR Senor Play
09/05/2019 at 21:09 • 0 commentsAt night the clock can get kind of bright and during the day it is just the dog watching the clock. I wanted a clean way to display the time without having to push a button.
Well, I have a HC-SR501 PIR Sensor laying around. So tonight (I don't have the clock with me) and going to play around some. I want to get the skeleton code to add to the clock when I get home. I added a 8x8 matrix display, it makes it a little more like the project that it will integrate into.
// Libraries required #include <Adafruit_LEDBackpack.h> #include <Adafruit_GFX.h> #include <gfxfont.h> // Definitions and variables #define pirPin 2 int calibrationTime = 30; long unsigned int lowIn; long unsigned int pause = 5000; boolean lockLow = true; boolean takeLowTime; int PIRValue = 0; // Setup the 8x8 matrix Adafruit_8x8matrix matrix = Adafruit_8x8matrix(); void setup() { Serial.begin(9600); pinMode(pirPin, INPUT); matrix.begin(0x74); } void loop() { // Calling the sensor function PIRSensor(); } void PIRSensor() { // If there is motion, put something on the scree if(digitalRead(pirPin) == HIGH) { if(lockLow) { PIRValue = 1; lockLow = false; Serial.println("Motion detected."); matrix.clear(); matrix.setCursor(2,1); matrix.print("B"); matrix.writeDisplay(); delay(50); } takeLowTime = true; } // No more motion, clear the screen if(digitalRead(pirPin) == LOW) { if(takeLowTime){ lowIn = millis();takeLowTime = false; } if(!lockLow && millis() - lowIn > pause) { PIRValue = 0; lockLow = true; Serial.println("Motion ended."); matrix.clear(); matrix.writeDisplay(); delay(50); } } }
-
Some things to work on
08/30/2019 at 21:12 • 0 commentsNow that the puttering is over and I have put a little more thought into this project; I am going to extend it a bit. I also dug up 2 additional 8x8's last night so I can expand the screen up or sideways.
I am going to try and keep myself honest and put up my TO DO list for this project. It seems a bit too simple and needs are little something, something to kick it up a notch. And not a fancy case.
- 3 buttons. Mode, Up, and Down
- Alarm, start with single
- Time set function
- Numbers scroll up and down off the screen
- replicate on ARM M4 with circuit python
- PCB?