Home Technology How to Learn Electronic Programming with Arduino

How to Learn Electronic Programming with Arduino

911

For the technically minded, Arduino can be a fun electronics kit to tinker around it. But it can have a pretty steep learning curve, especially if one is lacking knowledge about electronics or programming. This article aims to clarify and demystify arduino programming.arduino

Step 1. Learn C

Programming Arduino is done via C. Without knowledge of C, you wouldn’t get anywhere. Thankfully, there’s a lot of C tutorials in the internet. A good site to use is Learn-C, it has an interactive code window so you wouldn’t need to download anything. Follow the tutorial on that site and you’ll get C basics down in no time .

If you’re a visual learner, this youtube video series would be for you.

Step 2. Download the Arduino IDE.

Once you’ve got the basics of C down, it’s time to understand how programming in Arduino works. First, programming the Arduino is done via their own packaged IDE. Get the Arduino software here. Install the software and connect it your Arduino board. If the IDE isn’t detecting your Arduino board, make sure you have the drivers installed.

Step 3. Understanding Arduino Programming
Now we can finally start programming in Arduino. Here’s an example Hello World code for Arduino:

void setup() {
pinMode (13, OUTPUT );
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

Unlike traditional C, where code starts at the int main() function, Arduino has two default functions, the setup() and the loop(). The setup() function is called by Arduino only once when it starts and is used to initialize your board. In the example code above we set Pin 13 into output mode. pinMode() is a built-in function Arduino function that sets a pin into either INPUT or OUTPUT mode. On most arduino boards, Pin 13 is connected to the led. By setting it to output mode, we are telling Arduino that we want to send a command to it.

The loop() function is where your main code will be. Arduino will loop through this function repeatedly during its run. digitalWrite is a built-in Arduino function that sends a voltage to the pin. digitalWrite(13, HIGH) means ‘send a 5V voltage into pin 13’, in effect turning on the led. delay(1000) means wait for 1000 milliseconds before going to the next step. Then we have a digitalWrite(13, LOW), LOW makes Arduino send 0V to pin 13 making the led turn off. Finally we have a delay again for 1 second.

As you can see, the code above turns the led on for 1 second, then turns the led off for 1 second, looped repeatedly. Now let’s run it.

Step 4. Upload the Code to Arduino

Unlike traditional programming, you just can’t compile the code to make it run. First, you have to upload it into the Arduino. On the Arduino IDE go to Tools -> Board and select your Arduino board. Make sure you selected the right option.

Upload the Code to Arduino

Find the serial port of your Arduino. On Windows, open up device manager and go to the Ports. Find the entry that says USB Serial Port and take note of the COM# after it.

In this picture Arduino is connected at COM5. Now go to Tools -> Serial Port and select the port where Arduino is connected.

IDEGo to File -> Upload to I/0 Board and wait for it to finish. You should see a “Done Uploading” message in the IDE. Now check your Arduino, if all goes well it should be blinking every 1 second. Congratulations, you have programmed your Arduino.

Step 5. Next Step

Now that you’ve learned the basics it’s time to learn more. You can buy Arduino starter kits or Make: Arduino Bots and Gadgets online or in your local electronics shop. These kits and books give you a step by step hardware guide on building various robots and gadgets with Arduino.

Amazing Arduino projects Videos:

Liked it?
Summary
Please share your ratings about this article! If you like it, please share it in your social profiles and other shareable platforms.
0 %
Rate and Share it!
User Rating 0 Be the first one !

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

How To Use Your Smartphone Abroad Without Going Broke

Using your phone abroad does not have to leave a massive hole in your wallet. There are wa…