Financial Literacy With Makey Makey
by Digijeunes in Circuits > Electronics
76 Views, 1 Favorites, 0 Comments
Financial Literacy With Makey Makey
Learning the basics of coding by making a simple calculator capable of addition only. This activity will introduce the concept of variable as well as the concept of a “random number’’.
Parts:
- Computer with scratch offline editor installed
- Makey makey (or DIY makey makey with Arduino Leonardo) + USB cable
- Coins (0.01, 0.02, 0.05, 0.10, 0.20, 0.50, 1, 2 EUR)
- 1 alligator cable per each coin + 1 cable for the ground
Activity
If it’s your first installation of Makey makey or Arduino Leonardo on Windows or MacOS, just plug the board to your computer and wait for the automatic installation. (2 minutes maximum).
Next, plug some alligator clips into the board.
Coding
Let’s get started with the coding.
To declare a variable go to DATA (orange), and click on ‘make a variable’ and give a name to the value. For this exercise you will need two variables: 1. ‘price objective’ and 2. ‘bucket’. Price objective corresponds to the price of an item, whereas bucket corresponds to the amount of money we spend. Next, pick up two blocks of the type ‘set …. to 0’ add one block per each variable (one for bucket and one for price objective) to the code. For the variable ‘price objective’ add a block ‘change …. by 1’ and go to OPERATORS (Light green), and replace the 1 in ‘change by one’ with the block ‘pick random 1 to 50’.
At this stage you should have a price objective and an empty bucket variable.
In a “forever” loop (available under CONTROL), pick the condition of you first key.
IF key ... pressed? THEN
In our example the key will be represented by a coin, so we will use the value of coins to define the extent to which the ‘bucket’ variable will increase.For example, for 1 euro choose the value 1 and for 10 euro cents (0.10 euro) set to 0.1.
To change the value go to Data (orange) and choose ‘change … by 1’, and modify it to have ‘change bucket by (the value of coin)’.To improve the code add a ‘wait 0.20 seconds’ (available under CONTROL) in each conditional statement. Repeat the operation for each coin.
Important! to avoid problems you need to add an end to your code. In this example, when the bucket value will be equal to the price, that will mark the end of the code.We need to add an IF (yellow) and use the OPERATOR (light green) ‘... = ....’. In our case we will add our variables (‘bucket’ and ‘price objective’ from DATA (orange):
The Final Code
After all this steps, your code should look like this: