|
Programming Arduino - Start
First plug your USB cable in to your Arduino and your computer. The USB cable powers the device. Arduinos can run standalone by using a power supply.
Once you’re done programming and don’t require it to be constantly connected to your machine you can opt to power it separately. This is entirely dependant on the use case and circumstances you want to use the device in.
Download Arduino Software
You’ll need to download the Arduino Software package for your operating system from the Arduino download page.
When you’ve downloaded and opened the application you should see something like this:
This is where you type the code you want to compile and send to the Arduino board.
The Initial Setup
We need to setup the environment to 'Tools' menu and select 'Board'.
Then select the type of Arduino you want to program.
The Code
The code you write for your Arduino are known as sketches. They are written in C++ or C.
Every sketch needs two void type functions, setup() and loop(). A void type function doesn’t return any value.
The setup() method is ran once at the just after the Arduino is powered up and the loop() method is ran continuously afterwards. The setup() is where you want to do any initialisation steps, and in loop() you want to run the code you want to run over and over again.
So, your basic sketch or program should look like this:
After making the program, you want to compile to machine code and deploy or upload it to the Arduino.
Compiling the Code
First you have to select the serial port:
Go to the Tools menu, then Serial Port
Once you have selected your serial or COM port you can then press the button with the arrow pointing to the right.
Once that happens you should see the TX and RX LEDs below the L LED flash. This is the communication going on between the computer and the Arduino. The L may flicker too. Once this dance is complete your program should be running. And your LED should be off.
|