I am building an ATM using my LEGO Mindstorms EV3, but I ran across a problem. The problem is that I want to be able to input the amount of money that I want to get out of the ATM but I can only have a maximum of three touch sensors because I'm using the fourth for the ability to have a key so my siblings don't steal money.

How can I can make an ATM with a maximum of three input to decide how many 20s, 10s, 5s, and 1s I want.


The possible solutions involve realizing that you can multiply the number of possible inputs by implementing long clicks, double clicks, click-and-holds, simultaneous clicks, etc. on the buttons. If I were you, I'd also include a Confirm and maybe a Cancel buttons, but the latter can be substituted by a timeout. You could ease your job if you don't handle the separate bills as individual amounts, but set the requested amount of money and write a function that splits an amount into separate bills (e.g. splitting 58 into 2×20, 1×10, 1×5, 3×1).

With these in mind, have a look at these example button mappings:

Solution #1:

  • Button 1: Increase amount by 1
  • Button 2: Decrease amount by 1
  • Button 3: Confirm

Solution #2:

  • Button 1: Increase amount by 1; Long press: increase amount while being held
  • Button 2: Decrease amount by 1; Long press: decrease amount while being held
  • Button 3: Confirm

Solution #3:

  • Button 1: Add 1
  • Button 2: Add 5
  • Buttons 1+2 simultaneously: Add 10
  • Button 3: Add 20
  • Buttons 1+2+3 simultaneously: Confirm

Solution #4:

  • Button 1: Increase amount by 1
  • Button 2: Cancel
  • Button 3: Confirm

Of course each approach requires different sub-solutions (as mentioned above, timeouts, detection of long presses and button holds, simultanous presses, etc.). These are up to you, but if you get stuck, feel free to ask :)

| improve this answer | |

Use a Motor as Input

You may be limited by the amount of touch sensors you can use, but you have one very useful form of input that you may not be aware of.

EV3 motors have the ability to provide a value based on rotation in degrees. Adjusting the rotation of the motor by hand, you can input very precise numbers quickly. To rotate the motor easily, attach any Technic wheel/gear to the motor using an axle.

Programming a Basic Dial Input

enter image description here

Create a unlimited loop block, this will ensure the current rotation value is always updated. Place a rotation sensor block, set to measure in degrees.

enter image description here

The rotation sensor is very sensitive, it's almost too sensitive because it makes it very difficult to select a number without jumping to another. I recommend you divide the output from the previous block by any number between 10 to 70 to decrease the sensitivity. (10 being the most sensitive).

enter image description here

The divided numbers are now non-integers, we don't want to be able to take out a fraction of a dollar/pound or whatever currency you are using.

Use the round block to round the divided numbers up to a whole number.

enter image description here

Optional: Add a currency prefix. You can use the text block to add a currency prefix, in this case I used the $ sign. EV3 only excepts the $ currency in text inputs. If you would like to use a different currency you would have to render it as an image.

enter image description here

Display the current amount selected using the display block.

Program Overview

Working Example

YouTube Link

| improve this answer | |
  • 2
    Nice MinuteBot base you have there. ;) – gev Sep 1 '15 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.