Shop OBEX P1 Docs P2 Docs Learn Events
Request Help with code for input slide switches — Parallax Forums

Request Help with code for input slide switches

T&E EngineerT&E Engineer Posts: 1,396
edited 2007-08-21 17:27 in General Discussion
As many of you may know I have been working on a Digital Counting Coin Bank which works well if I only used pushbutton switches to represent coin droping (e.g. 1 pushbutton for a penny, 1 pushbutton for a quarter, etc.).

Here is the posting for detail:
http://forums.parallax.com/showthread.php?p=660476

However, the coin droping switch mechinism was a bit more complicated then I planned and it isn't as simple as just hitting a single pushbutton for each coin drop.

It is spring loaded (see attachment JPG) and always rests at the default position. When a coin is dropped (e.g. a Quarter) it slides the metal bar over the contacts (from the default, over the dime, over the penny, over the nickel and then to the quarter. THEN...it springs back over the nickel, over the penny, over the dime and finally rests back on the default).

So, to simulate this...the user has to press:
1. a default button
2. a dime button
3.·a penny button
4. a nickel button
5. a quarter button
6. a nickel button
7. a penny button
8. a dime button
9. a default button

Not so simple and surely not just a single pushbutton (e.g. a quarter) that I had not thought out yet.


How is it possible to check for a "quarter" button press knowing it has to travel from default to quarter and then back to default again?

I was thinking it might be related to checking for timing via PAUSE statements but not quite sure about this.


If anyone can post their ideas, I would be happy to listen and gratefull.


(Besides the coin drop switch jpg, I have also attached the current working program - if only single pushbuttons were used.)

Thanks again!
648 x 486 - 21K

Comments

  • CCraigCCraig Posts: 163
    edited 2007-08-20 13:20
    I only glanced over the code. I didn't understand the DO LOOP on btns = %11111111.
    Shouldn't the jar btns read the default %11111110, when at rest? or is the jar sleeping or something?

    If so then I'd loop on the default. When you lose bit.0 (default) then capture the highest value of the btns until you regain bit.0 (back at default).

    I'm assuming that bit.0 switch breaks before makes contact.

    HTH, Chris

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not scared of your robot. I'm covered by Old Glory (youtube)
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-08-20 15:35
    I don't think it's going to be as simple as just reading the switches;
    -- wait for non-default input
    -- keep track of maximum coin value
    -- wait for return to default input
    -- log maximum coin value

    This assumes, of course, that you don't insert a coin half-way and then pull it out -- that would give a false coin value.
  • Basic JimBasic Jim Posts: 106
    edited 2007-08-21 17:27

    Hello T&E,

    My first project about two years ago was to replace my broken money mill. It would sort coins but didn’t count them. I figured it would be a good first project to use the sorter part to sort and count them using an SX48 project board. If you can use photo diodes for your project I would recommend it. They are more reliable and won’t wear out as fast as mechanical switches will. Mechanical contacts wear or become oxidized over time. I got mine from old serial nice I had laying around.

    How it works is, you drop the coins in the tray. The tray is slanted and one of the coins will slide into the dark wood area where a photo diode will sense it and activate a servo motor that turns an AOL CD ‘modified’ to scoop up a coin an bring it to a hole. The coin drops into the hole and gets sorted according to size. As it goes down the shoot into its proper coin roll it trips another photo diode that adds that coins value to the total and is shown on the LED display. When the count reaches the number of coins for that roll the display says XX FULL. It works pretty well but it’s not very pretty as you can see in the picture. Someday I will revisit this project and add more features and take a pretty stick to it. If your interested I can post the code for it.

    1792 x 1200 - 174K
Sign In or Register to comment.