Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

clap switch with PIC16F876A

Status
Not open for further replies.

jean12

Advanced Member level 2
Advanced Member level 2
Joined
Aug 27, 2013
Messages
529
Helped
5
Reputation
12
Reaction score
6
Trophy points
18
www.ntigltd.com
Activity points
5,497
Hello,there I would like to contruct a clap switch basing on PIC16F876A and a condenser;when clapping for the first time a LED gets ON on PIN_C2;when clapping for the second time the LED turns off.

can you please help me coding;I use CCS C Compiler and Mikroc(without interrupts).


Thanks.
 

Use interrupts. Use an OP-Amp to amplify the mic o/p then use a Comparator to detect level. If there is a clap the Comparator o/p should either go high (5V) or low (0V). Detect this using uC and do whatever action you want to do.
 

The problem is programming I've never used the comparator,so can you pleas help me to deal with?

Thanks.
 

with external is another issue I want to use internal ones.

If I use LM324 for comparator making can you pleas provide the complete circuit including PIC?


What do you propose;what will be the conversion used for detecting that voltage from the condenser??
Please help.


Thanks.
 

https://obrazki.elektroda.pl/1720811700_1378835929.jpg

This circuit is a substitute for LM324 comparator. This uses a BC547 npn transistor and is biased in such a way that it only gives either 5V or 0V.
Values for resistors are R1=1kohm, R2=R3=R4=330ohm.

You can feed this signal to your microcontroller and proceed as needed
 

Hello there,see the circuit here ,I want to make it so that when clapping one time the PIC output 1 on its D1 pin and command the Relay for ON status,when clapping two times the relay comes back in its open state and make OFF the lamp.

I use CCS C compiler.

Thanks.
 

Attachments

  • Clap Crt.zip
    11.9 KB · Views: 73

If using comparator is causing problem then use adc. Connect mic o/p to ADC and measure the ADC value. Then clap and measure the ADC value. If ADC value comes around say 512 out of 1023 then you can write in code such that if adc value is greater than 450 then do what ever you want to do.
 

Just help me with that by adc,but also there is a problem of knowing what will be the adc value when I clap two times and when I clap one time;I was just thinking in those manner but I am some how confusing the thinks;

I have to clap one time for making on the system and clapping two times for making of the system,help me to think on the codes in ccs c compiler.

Thanks.
 

A timer has to be used like say for 2 sec. If first clap is detected then timer is started and if second clap is not received within 1 sec or 2 sec after first clap then it is treated as One clap, if second clap is received within the time then it is considered as two claps.
 

can you please help me to setup the timers as required;I get the point very well of setting the timer but I don't know how to use them can you help me please?

Thanks.
 

Hello see the codes I used,I am only making the load ON,can you please help me to make it OFF when clapping two times within 10s between the first clap and the second??

Thanks.
PHP:
#include "16f877a.h" 
#device adc=10 
#fuses HS,NOWDT,NOLVP,NOCPD 
#use delay(clock=4M) 

 

float volt, oldval,volt1 ;
 
void main()
{
    set_tris_a(0xff);
    set_tris_b(0x00);
    set_tris_c(0x00);
     set_tris_d(0x00);
    
    setup_comparator(NC_NC_NC_NC);
    setup_adc(ADC_CLOCK_INTERNAL);
    setup_adc_ports(AN0);
    set_adc_channel(0);
    setup_vref(FALSE);

output_d(0x00);
    
    while(1)
    {
        delay_us(20);
        read_adc(adc_start_only);
        delay_us(100);
        volt = read_adc(adc_read_only);
        volt = volt * 30.0/ 1023.0;
                
      if(volt>1)

                {
delay_ms(3);
output_high(PIN_D0);
delay_ms(10000);
	}

    }    
}
and also the load be able to be OFF only when clapping two times within the 10seconds not after the defined delay in the codes.

Thanks,please help.
 

I want to request yo just to help me to do so,by adding the timer codes in the above posted so the project can turn on (clapping only one time) and off the Load (with clapping twice).

Thanks.
 

Hello,here is the project for clap switch.

Help me to use it as an ON and OFF switch.

Thanks.
 

Attachments

  • Clap Switch.zip
    17.2 KB · Views: 75

Hello,the voltage I get is of 1.4V when clapping.
But I am using that voltage just for making the Load ON but I want when clapping two times with 10s to turn off the same load.

Please help.Thanks.!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top