Monthly Members’ Competition
Competition Date: 5 to 11 Oct 2020
LCD / Button at D2 / Button at D4
This is a memory quiz that shows the user a string consisting of ‘0’s and ‘1’s for a few seconds and asks the user to enter the same string. For example, the programme may show “100110” to the user and then the user has to input “100110”.
The programme will run in the following sequence:
1. Show the instructions below to the user on the LCD:
Using button D2 to represent 0
and button D4 to represent 1
enter this code in same order
2. Generate a random string that is between 4 to 8 characters long and consisting of only ‘0’s and ‘1’s (eg.”0101″, “11100”, “11010010” etc)
3. Display the string on the LCD
4. Allow the user to enter the characters one by one by pressing and releasing the buttons (Button D2 for “0” and Button D4 for “1”.).
5. Show the string that the user has entered as the user is entering each character (refresh at 0.2 sec interval).
6. Once the user makes a mistake, show “Incorrect!” followed by the correct string to enter and end the program.
7. If the user completes the string, show “Correct!” and end the program.
Hints: – You need to use variable. Watch this clip on how to use variable. (link to the youtube clip on variable)
– The Random block returns a random number within the specified range
– You can manipulate text in this way
Create the program as described above. No hard coding (ie. a series of ifs with every possible conditions is not allowed).
Instead of entering the string in the same order, the user has to enter the string in reverse order in order to win.