Recently I have been kicking myself for forgetting to turn off the motor that pumps water from a sump to an overhead tank at home. Every time I turn on the motor, I try to remember to turn it off in 30 minutes (about the time it takes to fill up the overhead tank from empty to full), but I keep forgetting to turn it off most of the time, wasting a lot of water before I realize it. Then I got an idea. Why not just make a simple, cost effective timer circuit that will turn off the motor after say 30 minutes? So I started thinking about it. All I need is a 555 timer and the correct resistors and capacitors that will delay the timer for the exact time I want the motor to stay on. Next I need a relay to control the motor. First the timer has to run in monostable mode. We just need a one-shot pulse. The pulse should be long enough to keep running the motor. Next we use t = 1.1RC to get the approximate time (in seconds) the output of 555 timer will be high based on the R (in ohms) and C
In my last post , I played a bit with the wireless relays to turn on a light. In this post I will show how to use LDR to detect when to turn on the light depending on the ambient light. Lets dive into the code quickly #define TRUE 1 #define FALSE 0 int LIGHT_PIN = 7; int SLEEP_TIME = 100; int LDR_PIN = 3; int LDR_THRESHOLD_FOR_DARK = 350; int MAX_COUNT_BEFORE_TOGGLE = 10; int isLightOn = FALSE; int toggleCount = 0; void setup() { turnOffDevice(LIGHT_PIN); digitalWrite(LIGHT_PIN, LOW); Serial.begin(115200); } void turnOffDevice(int pin) { pinMode(pin, INPUT); } void turnOnDevice(int pin) { pinMode(pin, OUTPUT); } void toggleLight() { if (isLightOn) { turnOffDevice(LIGHT_PIN); isLightOn = FALSE; } else { turnOnDevice(LIGHT_PIN); isLightOn = TRUE; } } void toggleLightIfNecessary(int input, int threshold) { if (input > threshold) { toggleCount++; if (toggleCou