​ ​ ​ ​ clap clap switch
Results 1 to 3 of 3

Thread: clap clap switch

  1. #1
    New Member
    Join Date
    Feb 2012

    Default clap clap switch

    Hi this is my third picaxe project that has worked. Quick vid on youtube


    two transisters amplify the mic send a signal to the picaxe 08m2 which then reads the first clap goes to a for loop and then checks every cycle for another clap before the loop runs out. If it reads another clap it jumps to see if the light's on or off and does the necessary job then returns waiting for input. There is another transistor used to up the current from the output of the 08m2 the relay needs 32.5mA to switch on. That was fun working that problem out.

    The relay is switching 240 volts I bought a project box from ebay to house the workings and being 240v for safety as well. If you check out my other vids there is a breadboard version but works off a single clap or sneeze or cough so a lot of false triggering hence I opted for the double clap program

    here is link for single clapper on the breadboard


    I will post the code shortly as I have seen others looking for this type of thing and not much in the way of help coming forward so check back.

  2. #2
    Senior Member
    Join Date
    Jan 1970
    Rangiora, New Zealand


    Good job.
    Did you decide on the second 'clap' activation after getting erroneous triggers?
    In theory, there is no difference between theory and practice. In practice, there is...

  3. #3
    New Member
    Join Date
    Feb 2012


    Thanks Mpep and yes it seemed that if my daughter sneezed or coughed it came on so she gave the orders to modify it. The code is below nice and simple could probably be improved upon but does what it says on the tin

    Just waits for a clap ( or loud sound) then jumps to a sub routine that uses a for next loop to wait for another clap (or loud noise) if it receives one then jumps to the light on off routine if not it resets the first clap and goes back to the start.

    As the meerkats say simples

    '* clap clap switch V1 *
    '* by AJ May 2012      *
    symbol clap1 = b0 'first clap
    symbol clap2 = b1 ' second clap
    symbol counter = b2 ' counter for countdown
    symbol light_condition = b3 ' light condition on or off
     readadc c.4,clap1 'read pin 4 for input
     if clap1 >157 then gosub countdown '' only do this if clap is heard
    goto main
     for counter = 0 to 250' use this as a timer
      readadc c.4,clap2 ' watch pin 4 for another clap
      if clap2 >157 then gosub switch_action' if a clap is heared do this
     next counter
     clap1 =0 ' no clap so reset clap1
     clap2 =0 ' reset clap2
     counter =250 '' when returned countdown is set to 0 and for loop will end
     light_condition = light_condition +1 ' this is to set light condition
     if light_condition = 1 then high c.2 ' if condition is 1 turn light on
     end if
     if light_condition = 2 then gosub turn_off ' otherwise light is on so turn it off
     low c.2
     light_condition =0


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts