NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Clap On Clap Off Relay Switch?

September 01, 2011
by Sovereign
Sovereign's Avatar

Hello there! First off let me say I'm rather new at this and after looking at the sound meter program I was wondering if this could be used with the buzzer (or a mic of necessary) to create a "clap on clap off" relay switch. And if so how can it be done? Thanks for the help!

September 01, 2011
by rajabalu21
rajabalu21's Avatar

Take a look at this. It should give you the basic idea. If you want to use the Piezo as the mic then please have a look at this. Yes, the sound meter setup can be used as a Clap to on/off switch. You may want to turn on and off an LED first and then work towards a relay to control AC load.

-Raja

September 01, 2011
by Sovereign
Sovereign's Avatar

Again Im a bit new (to programming not curcuitry) would you happen to know how to use the code designed for an ATMega16 on the 168? Thanks.

September 01, 2011
by Sovereign
Sovereign's Avatar

*circuitry

September 01, 2011
by hariharan
hariharan's Avatar

if it is just an i/o application, change the registers . for the lcd, use nerdkits library.

September 01, 2011
by Sovereign
Sovereign's Avatar

This is the error that gets me. The switch is activated and battery is in COM is set correctly etc. http://img684.imageshack.us/img684/156/capturecjd.jpg

September 01, 2011
by hariharan
hariharan's Avatar

what is the program u compiled? maybe u should post it so someone could solve ur problem.

September 01, 2011
by Sovereign
Sovereign's Avatar

http://elf.cs.pub.ro/pm/wiki/_media/prj2011/dloghin/clap_switch.zip here it is thanks so much!

September 01, 2011
by Sovereign
Sovereign's Avatar

Also this is the project http://elf.cs.pub.ro/pm/wiki/prj2011/dloghin/clap_switch

September 01, 2011
by hariharan
hariharan's Avatar

i don't think there is a PA7 or a PORTA on the atmega168, that might have been the problem

September 01, 2011
by hariharan
hariharan's Avatar

awesome project! may be, i'll try to make a clap produce a tone on the peizo buzzer and two claps produce another tone, and so on !

September 01, 2011
by Sovereign
Sovereign's Avatar

Alright since those outputs are missing which ones can I use instead and how should I update the code? I think I have the PA7 problem solved but now I need the PORTA. But, in case I'm wrong would someone be so kind as to point me in the right direction? Thanks!

September 01, 2011
by hariharan
hariharan's Avatar

maybe u should make the circuit into a ac to dc where if done, you could use the pin change interrupts(since the output will be a high or low).a circuit like this:http://en.wikipedia.org/wiki/File:Diode_bridge_smoothing.svg . the programming will become simple too. using case and break in c , u can make it more good. if u really have to use the adc, then u should use some parts of the code from the nerdkits guide and the temperature sensor project.

September 02, 2011
by Sovereign
Sovereign's Avatar

Not sure what AC to DC conversion has to do with anything... Never said I'd be using AC current. Anyway basically I do not understand what would need to be changed to fix the code. If someone could do that for me and or tell me how it was done it would be MUCH appreciated.

September 02, 2011
by bretm
bretm's Avatar

Look at the full atmega168 datasheet on page 2 where it shows the pin names. Look at your atmega to see which pins are unused and change the code to use those pins. Which pins were you going to hook the piezo and outputs to?

September 02, 2011
by Sovereign
Sovereign's Avatar

Well take a look at this schematic http://elf.cs.pub.ro/pm/wiki/_media/prj2011/dloghin/clap_switch.png?cache= PC0, 1, and 2 are fine as those codes havent changed. It is only PA7 (ADC7) that is the problem. That is where the mic and transistors interface with the circuit. Also note that in the code it references PORTA and that gives me an error (along with the other non-existent pin) look back at the links in the post to see my error if you need. But what Im asking is how that would be changed in the code and what pin should I use. Does it matter? And again how can that be done. Thanks so much.

September 02, 2011
by hariharan
hariharan's Avatar

since there is no PORTA in the mcu, the input should be set to PORTC for PC0 or any other one. if you want to check for the input pins, check page 256 and 257 on the datasheet. if u want PC0 to be the input, declare it as input in the main function and in the'SET_ADC_CH(ch)' set the admux=0 (the pages 256 and 257 will explain u why). i think that should help.

September 03, 2011
by Sovereign
Sovereign's Avatar

Modified the code. Just as a final check could someone verify that this code will indeed work as intended. And what pin would be the input on the schematic (ADC input) and where the output for the LEDs will now be? Thanks so much! Here is my modified code: http://www.megaupload.com/?d=4QQXUR7D It compiles perfectly. Im just making sure it will all work before buying parts/testing.

Post a Reply

Please log in to post a reply.

Did you know that interrupts can cause problems if you're not careful about timing and memory access? Learn more...