Skip to main content

Posts

Power Off Delay Circuit

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
Recent posts

InduinoX and wireless relays: Part II

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

InduinoX and wireless relays: Part I

It has been a while since I received my wireless relay and I finally got some time this weekend to put them to good use. The connections were really simple. I connected a 5V DC power supply (check polarity, the center pin should be positive) to the wireless transmitter and a 12V DC power supply to the relay board (which also has the receiver). To control the relays using InduinoX, I connected the wireless transmitter board ground to the InduinoX board's ground. Connected the relay 0 pin on the board to digital pin 7 on InduinoX. Finally connecte the light bulb to mains neutral, the live from mains to the common pin on the relay and "normally closed" (NC) pin on the relay to the light bulb. Generally you would connect the "Normally open" (NO) pin to the light bulb instead of NC, but I will explain in a minute why I had to connect NC. Now to the coding part. The specification for the relay tells us that when the relay pin is open (high impedance),

Scopes and electronics

An oscilloscope is very important for any electronic enthusiast. Recently I have been trying to send IR remote codes from an arduino board to my TV. I was having some trouble with timings and my TV would not respond properly. Without the oscilloscope this would not have been easy to debug. I have been looking for some not very expensive, simple to use oscilloscope that can be connected to my computer, so I can save data. I came upon PicoScope . They have a wide variety of products, but the one that caught my eye is the PicoScope 2205  which came in my budget and good enough for my projects. However it is not available in India. Lucky for me my sister and brother-in-law are in UK! I asked them for the PicoScope 2205 and 2 probes (x1 and x10). Thanks to them I now have an oscilloscope. Contents of PicoScope 2205 and Probes So when I had to find the IR signal coming from my TV remote, I connected the probe to the IR receiver data out pin on the arduino board and started rec

InduinoX: IR Emitter

In my last post , I promised an arduino board based remote control. This is the post you have been waiting for. Now the InduinoX comes with an IR emitter too (don't you just love this board?)! The IR emitter is connected to analog pin 0. So you can start transmitting the remote signal you previously discovered. Before we go too far, make sure you have read the primer on IR remotes . My TV remote sends out the signal in the sony protocol as observed from my gnuplots and oscilloscope. You know now that according to Sony protocol, a 1 is represented by 1200ms of high and 600ms of low, while a 0 is represented by 600ms of high and 600ms of low. Also the signal is to be prefixed with a header, which is 2400ms high signal followed by a 600ms of low. So lets write some code to send the header, 0 and 1 first. #define HEADER_ON    2400 #define HEADER_OFF   600 #define BIT_1_ON     1200 #define BIT_1_OFF    600 #define BIT_0_ON     600 #define BIT_0_OFF    600 void sendHeader()

InduinoX: IR receiver

From my previous post , you probably understood how IR remotes work in general. Now lets take a look at how we can read the signals coming from various remotes that you might have. Fortunately for us the InduinoX board comes with an IR receiver. And the good news is that  some one already wrote the code  to read IR signal from arduino! Just copy the code from  http://www.arduino.cc/playground/Code/InfraredReceivers , replace the value of IRpin from 2 to A1, because on InduinoX, the IR receiver is connected to analog pin 1. Compile and upload the code to InduinoX. The code basically sets up the serial port to 115200 baud rate, then sets up timers (read this excellent tutorial on PWMs on arduino), finally the code waits on the IR receive pin for the signal to change (the signal changes when a button on a remote is pressed pointing to the IR receiver). Then the code keeps track of the time it takes for the signal to change from high to low and low to high. At the end of the signal t

IR remotes

As part of my  home automation project , I also wanted to control my home entertainment system. The controller can be a web interface or an app on android phone, or even a universal remote. Which means, I have to be able to send IR signals from the arduino board that my TV, amplifier and set-top box can understand. For this I will first have to read the signal coming from the remotes, store the various signals and replay them from the arduino board depending on my needs. Before going too far into the details of receiving and sending IR signals, it would help to understand how a remote control actually works. There is already a lot of material on the internet on how remotes work. So I will try to keep it short and simple. The IR transmission from remote to your device works on a really simple protocol. The transmitter which is just an LED that emits light in the infrared spectrum, pulses the light in a quick succession and the receiver which is a phototransistor, converts the light