The arduino software has a really nice colour coding scheme, when you type the commands shown below they should turn orange – if not you may have typed it wrong, pay attention to capital letters, spacing and semi colons.
1. pinMode(pin number, OUTPUT or INPUT)
When you are attaching stuff to the arduino, you need to tell the arduino which port, or pin number it is plugged into, to do this you need to use pinMode.
In the brackets the first number you type is the pin number, so, for example, if your led is connected to pin 12 your instruction will look like this:
You need to type OUTPUT next because the arduino will be sending a signal to the LED.
This command always goes in the void setup() function.
2. digitalWrite(pin number, HIGH or LOW)
This instruction tells the arduino to send a signal. For example, with the LED connected to pin 12 you would write:
digitalWrite(12, HIGH) or digitalWrite(12, LOW)
Can you figure out what the difference is between when you write HIGH or LOW?
This instruction tells the arduino to read in a signal from whatever is attached, this won’t work for an LED. It is used for buttons, sensors etc.
digitalWrite and digitalRead go in the void loop() function.