Every year we have a LEGO fan expo and I love to make creations that are interactive.  All too often kids are not allowed to touch anything at these expos and so they love it when they have a chance to touch something.

I first showed off this robot in 2016, but in 2017 I made some changes to make it a little more reliable.  Quick video below on how it works and if you keep scrolling, I’ll outline how the software works.

 

 

Software

The whole program was written in the EV3-G software, and is a nice example of how to use the Array functionality.

click for larger version

 

The software works as follows

Wait for the Green button to be pressed (this is the start button) and initialise an array that is 8 long

Chose a random number between 1 and 3 and then fill the array with 8 of these random numbers.  Each random number corresponds to a particular chime to be played.

I wasn’t happy with the default Random Number Generator as it was giving me way too many of the upper and lower bound values (1 and 3 in my case).  So I wrote my own.  Basically it chooses a random number between 0 and 4 and if it is not inside the range 1-3, it re-chooses the random number.

Play the sequence according to what round the player is up to.  ie.  if the play is at level 1, only play the first chime of the sequence. If the player is at level 6, then play the first 6 chimes in the sequence

 

Once the sequence has finished, wait for the player to press the corresponding buttons.  Each button is assigned a number that matches the chime number.  By checking if the button number matches the chime number, the robot can determine if the correct button was pressed.

If the player gets the sequence right, move to the next level, otherwise sound an Error alarm and reset back to the Start.

If the player gets through 8 rounds, then play all the chimes at once and have some cheering sounds.  This is in a Switch to make sure if the player doesn’t make it to the end (level 9) then they don’t get the cheering.

So there it is!  I have no doubt there are probably better / more efficient ways of doing it, but this works well.  Let me know what you think 🙂

Privacy Preference Center