I had an email from a teacher recently asking for some advice on how to put together a voting machine using the LEGO MINDSTORMS EV3. I quickly put together this example as a starting point.
The build is ridiculously easy – The EV3 and 2 Touch Sensors.
The program however is a little more complex. It would be a great way to teach a variety of more complex concepts like variables, parallel processing and looping.
(click for larger version)
There are three parallel tasks; Task 1 sets up a variable (Bob) and makes sure it is zero when the program starts. It then runs an unlimited loop in which it waits for a touch sensor to be ‘bumped’ (pressed and released). It then takes that variable and adds one to it and stores the number back into the variable. Task 2 does exactly the same thing for a different variable (Sue). Task 3 takes the Bob variable and combines it with some text so that the display says ‘Bob: 7″ as opposed to just the number by itself. It then displays that Text on the screen at position 0,0 (Top left). It then does the same thing with the Sue variable and puts it at position 0,3 (Middle left roughly). The important thing to note is that this second display block has the ‘Clear Screen’ input parameter set to FALSE to make sure that we don’t clear out our Bob Text.
If you wanted to extend it further, you could set the loops to run for only a few minutes, and then you a Compare Block and Switch Statement to declare a winner (or a draw!)
Let me know in the comments if you’ve done something similar.