This week we spoke a little bit more in depth about the coding.
Int (integer) = always whole numbers
Starting with variables
Pin mode – function needs to be set up, otherwise pin does not do anything (OUTPUT)
Structure
3 hearts:
(1) set up variables
(2) always a setup function (void)
(3) always loop function
for (int=9; i < 13; i++){
starts off with 9, adds 1 until 13)
We had the opportunity to practise with another example from the provided Arduino examples. This time we were supposed to turn on and off a LED by using a switch.
With the aid of a sketch on the given sheet we tried to create the same circuit. Unfortunately, we ignored Richard’s advice of using coloured wires according to their purpose. Red is supposed to be for the positive and green for the ground. Why is that actually? For me personally, red somehow gives the impression of being more negative. We just simply used yellow and orange wires pretending it does not make a difference. It does not really, but it just makes it harder to read the circuit.
After a few times of trying to upload the programme to the Arduino, we realised that we hadn’t specified the serial port, which makes it impossible to upload it. Once the software was uploaded, the LED still did not respond to switch. Only the little orange light on the board lighted up according to the switch. At that time we realised that the wrong colour of wire and chaotically long ones do not make it easier to find out where the mistake was. Still, we managed to check and found out that there wasn’t really a mistake. So, what was wrong? Why didn’t it work? It was the LED. The LED was plugged in the wrong way. It was just a matter of turning it the other way around to make it work. I have to confess, this little exercise made us proud and confident. Therefore, we didn’t really have the need of doing the advanced exercise with was implied two switches. The fact that we ran out of time may also have been a reason.
In the following “lecture” we looked at some coding with Josh. According to him, the problem with Arduino is that there are too many examples. On the one hand side, it makes it easy to find appropriate examples and to modify them to a form, which is usable for our own examples, but on the other hand, it restraints you when you want to code something for your own unique idea.