A function is basically a series of steps that you teach the computer – it then learns the steps and can use them when you ‘call it’. The idea is you don’t need to continually tell the computer how to do something as it already knows.
In this case, we are going to teach the computer how to work out the percentage of a number. The steps are:
Take the number and divide it by 100
Multiply that answer by the percentage you want
Print out that answer
In Scratch, you can do this using the MAKE BLOCK function. You define the block and put in how many numbers you need. In the function, you define the steps and return the answer.
You then ‘call the function’ by adding the block to the code.
REPETITION is a very useful function on coding and saves time rather than doing a long list of code. The basic idea is that you can have a variable and then write code so the variable increases by 1 (or another number) until a certain number is reached.
Been trying to find a few ways to control one Arduino with another Arduino wirelessly. Bluetooth is one option but it can be difficult to set up and pair 2 devices. Radio control is another – simply use an Arduino to transmit a signal and have the other Arduino receive it.
This shows how the system works. It’s quick and very responsive.