Nathanael Padgett
  • Facebook
  • Flickr
  • Linkedin
  • Twitter
  • Vimeo
  • Home
  • Photography
    • Portfolio
    • Schedule A Session
    • Packages & Pricing
    • Frequently Asked Questions
  • Web Development Portfolio
  • Contact

Working Piezo & Momentary Switch :)

Home» Electronics » Working Piezo & Momentary Switch :)
Working Piezo & Momentary Switch :)

Got the momentary digital switch working with the PICAXE 08m microprocesser. The switch required some resistance so that it didn’t continually send an ON signal to the PICAXE. It was a pain because I didn’t have a single large enough resistor to use, so I had to use a resistor chip and run it through several of the pins for a similar effect. This was enough to make the digital switch work just fine. Some things I learned this evening:

  1. When code is in SLEEP, WAIT or PAUSE mode, you can’t upload a new program to the chip.
  2. Using a momentary switch as an On/Off switch by setting variables is difficult.
    Example Code:
    b1 = 1
    main:
    if pin3=1 then
    if b1=1 then
    b1 = 2
    else
    b1 = 1
    end if
    end if
    if b1 = 2 then
    sound 4,(120,500)
    end if
    goto main
    ‘ ————————————————————————-
    The problem with this script is that the button can be pressed at any time in the code; so if the button is pressed any time after it checks pin3 in the third line of code, it doesn’t actually register as a press. It has to be pressed at just the right time. The other issue is that if you press the switch for any length of time, the b1 variable might have a chance to be set several times; so by the time you let go of the switch, you have a 50% chance of the value actually being what it should be. — I’m not sure how to get around these issues without having an actual On/Off switch, instead of a momentary one. Circuit photo below….

Comments are closed.

  • 417-496-6275
  • Nathanael@NathanaelPadgett.com
    • Facebook
    • Twitter
    • Flickr
    • Linkedin
    • Vimeo
    • Email
Subscribe To My Newsletter!

Categories

  • Business (7)
  • Electronics (7)
  • Miscellaneous (4)
  • Photography (16)
  • Photography Page Slider (5)
  • Print/Graphic Design (1)
  • Programming (3)
  • R/C (3)
  • Web Development (11)

Latest Tweets

  • http://t.co/9fbay0KU
  • icontact new dashboard is so company driven - not customer driven; Learn to listen to what customers, not ram stuff down their throats.
  • Church logo intro: http://t.co/0NZGjx99 Unfinished, but still nice.

(c) 2012 Nathanael Padgett