Now let’s try to write simple code.
Open your Arduino IDE and type the codes below. I will not explain about the coding in this article yet. Just try it first.
This code will tell arduino to turn on and turn off the led light on arduino board or supply 5 volt to pin 13 every 1 second continuously.
———————————————————————————-
/* Program: Hello Word!!
Code by: Taufan */
const int pinLED = 13; // set pinLED as integer (number) with value13
void setup() {
pinMode(pinLED, OUTPUT); //set pin number 13 as Output.
}
void loop() {
digitalWrite(pinLED, HIGH); //supply voltage 5 volt via pin 13
delay(1000); //delay (keep turn on) for 1000 milli second (1 second).
digitalWrite(pinLED, LOW); //turn off the voltage at pin 13.
delay(1000); // keep turn off for 1 second
//repeat again.. (loop)
}
———————————————————————————-
After you type the codes, you verify it first or upload it to arduino board to run the program.
To verify the program, just click the ‘verify button’ with sign ‘√‘. Verify mean, it only check if there is any error codes.
Or, you can press ‘Upload button’. It will verify and upload the codes at the same time to Arduino board.
Compiling and uploading the codes to arduino board is done. You can see the information at the bottom. Your total codes is 1,076 bytes of 32,256 byte maximum that you upload to arduino.
You can check the result at your arduino board. The program will tell arduino board to turn on the led light for 1 second, turn it off for 1 second then turn it on again. It will be repeated until we upload another code to the arduino board. The codes will stay in the board even the power source is plug off.
You can insert the Led light directly to pin 13. The long leg is Anode (+) and Short Leg is Cathode (-). It’s recommended to use resistor to decrease the current otherwise it will burn your Led. But, you don’t need it for pin 13 in arduino. It has built in resistor already.
If you want to try with LED light, plug in the long leg to pin 13 and the short leg to GRN (ground) pin.
Well… happy trying.
Leave a Reply