Saturday 21 December 2013

Sound Sensor with Relay

Creating a "clap on" "clap off" light switch


Warning!

Because we are using mains power i feel i should give a little warning, the picture below shows cut wires with masking tape covering them, masking tape is not enough protective insulation! This was a quick test done in the middle of the night, as you can probably tell from both wires being cut!

Components

A strange sound sensor i found on amazon code HOT UK05, couldn't find a data sheet for this and hardly any information.

A Cheap version of a SainSmart relay module (4 channel).

An LED for debugging.

And a lamp you can cut the wires to.

Sound sensor

I set the sound sensor as a digital input and adjusted the sensitivity using the onboard potentiometer. That way when sound was detected above a certain threshold the pin was set low and this lit the LED up.

Relay module

Heres a really good website with lots of information about relays.

The Circuit


Conclusions

Using the sensor as a digital input it only has two states, on or off, if i wanted more accurate readings and control i would have to use it as an analoge input.

After programming this i feel alot more confident about checking states, last states then toggling a switch.





Wednesday 18 December 2013

LCD Display


Displaying two variables on a SainSmart LCD keypad shield

Intro

Displaying information on an LCD display is something i want to use in future projects.
I am trying to create a menu using the buttons on the shield but this is a little above my programming level at the moment. 

I could have made a simple menu where if i held "down", temperature is displayed or "up", the light level is displayed, however i want to create a "Real Menu" using arrays to store the different things to be displayed on the LCD and counters to control where we are in the menu and what is to be printed to the LCD.

The circuit


Code
Awesome code showing a menu
Good advice
Wiki



Monday 2 December 2013

PIR and Light Sensor to LED


Using two variables to control an event, in this case turning an LED on.

Automatic light

The Plan

Using a photo resistor and a proximity sensor i want to recreate the automatic light!

Photo resistor

When placed in darkness resistance is high and vice versa.
Used in a voltage divider circuit. We analog read the pin giving a reading between 0 and 5 volts which is then assigned a digital value between 0 and 1024. A great video on voltage dividers.



a voltage divider circuit

PIR

Stands for Passive infrared sensor (HC-SR501) 

Left pot. Adjusts sensitivity,  clockwise more sensitivity and vice versa

Right pot. Controls amount of time (delay) between movement and re-trigger i.e. when set to mid point the time between is 5 seconds. This is only useful if not using a micro controller,  however when using a micro controller the delay can be programmed. A more in depth explanation on how they work here


PIR sensor

The circuit


Conclusions

A relay could be wired up and this circuit could be used to control a light with more power.