Date post: | 05-Feb-2018 |
Category: |
Documents |
Upload: | dangkhuong |
View: | 215 times |
Download: | 2 times |
Love O Meter
We will use if, else if and else statements to check if you and a friend are a Love Match
One person will touch Pin 0 and theotehr GND. When you hold hands a circuit will be made which will start the program.
Add an on P0 pressed loop
Because the random number created will change this is called a variable.
Add a variable
At the moment the name of the variable is ‘item’. Change this to ‘LoveNumber’
The LoveNumber needs to create three random numbers, 0,1 or 2.
Add in ‘pick random’ 0 to 2
Add a message to say something appropriate
Add in if, else if, else conditions based on the size of the random number generated.
Add in strings to say what your ‘love match’ is
Challenge
1. See if you can add in extra messages by creating more random numbers2. See if you can get it to add in images as well as messages. Maybe these will be hearts of
different brightness depending on the love match3. See if you can develop a fortune teller game that tells your fortune when you make a
connection between P0 and GND
Answers