Skip to main content

Posts

Showing posts from 2011

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

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

InduinoX: Interfacing with the LDR

Now that I got my LCD display to work with the arduino board , I wanted to use it to show something useful. Since I needed to detect the ambient light for my home automation project , I decided to display the amount of light coming into a room using the light dependent resistor (LDR) that comes with the InduinoX board. Later I will use the LDR reading to determine whether I have to turn on the lights in the room or not. Typical LDR (Source: http://www.induino.com/wiki/index.php?title=File:LDR.jpg) The LDR's output is connected to analog pin 3. The voltage as read from pin 3 is inversely proportional to the light incident on it. The analog input is connected to a 10 bit analog to digital converter (ADC). Hence the values range from 0 (at 0V) to 1023 (at 5V). The analog pins can be referenced in the code using A0 (for analog input 0) to A5. For more information on analog inputs, check out  http://www.arduino.cc/en/Tutorial/AnalogInputPins . Now to get to the coding part #

Purchase experience with Probot

I have recently posted my purchase experience with Simple Labs . This post is the continuation of that. That same day I ordered these components from www.probots.co.in 4 channel wireless relay board Power supply for relay Power supply for transmitter The 4 port relay board will turn on/off any lights and fans connected to them. And the on/off state of these relays is controlled from the transmitter. The transmitter and receiver talk over a 433 MHz frequency in their own protocol. The transmitter controls the relays by the way of 4 physical buttons or by a micro controller like the arduino board. There are 5 pins on the transmitter (one for each of the relays and one ground) which should be connected to the arduino board. When a relay pin is connected to ground, the relay on the receiver turns on. When the relay pin is open, the relay is off. The relay requires a 12V DC supply and the transmitter requires a 5V DC supply, which also I purchased. Make sure the power supply co

InduinoX: Interfacing with LCD

After my quick Hello World app , I became a bit more adventurous and decided to interface with the LCD screen that was part of the basic kit from Simple Labs (see this post for more details). Fortunately, arduino has a library called LiquidCrystal to interface with LCD displays that are driven by Hitachi HD44780 compatible drivers. All you have to do is add a #include <LiquidCrystal.h> in your code to start using the library. But before going into the coding part, I had to first make the proper connections from the LCD display to the arduino board. I looked up the datasheet for my LCD display, but found a much simpler connection diagram over at  http://www.arduino.cc/en/Tutorial/LiquidCrystal . I did not make the exact connections like in the diagram. This is what I did LCD                            Arduino PIN 1 (GND)                    GND PIN 2 (Vcc)                    +5V PIN 3 (Contrast adjustment)    Voltage divider (see below) PIN 4 (Register select)        D

InduinoX: Blinking LEDs

Having received my arduino and basic components kit earlier last week , I sat out to write my first arduino program. A hello world of sorts. I started out by installing the arduino package in Kubuntu. What you get from the package is a simple IDE which can compile and upload the code to the arduino board. For installing the IDE on other flavors of linux, head on over to the arduino site . I connected the InduinoX board to my laptop using a USB cable. Selected the correct board type i n the IDE using   Tools --> Board --> Arduino Deceimila, Duemilanove, or Nano W/ ATmega 168 . Next select the correct USB to use fr om  Tools --> Serial Port . A nd finally wrote these first lines of arduino code :) void setup() {   pinMode(11, OUTPUT);  // Prepare red LED for output   pinMode(12, OUTPUT);   // Prepare blue LED for output   pinMode(13, OUTPUT);   // Prepare white LED for output } // a function which executes again and again void loop() {   redLight(HIGH);