Arduino : Explained

 

Introduction

One of the most common questions I see from people that are just entering electronics and programming is: what is Arduino? Well, Arduino is a platform for microcontroller devices that makes embedded programming much easier than traditional methods. Thanks to Arduino's simplicity and ease-of-use, embedded systems and programming now have a much lower barrier of entry than before. For only about Rs.500 (According of to this Link )you can get started in electronics, as opposed to a few hundred dollars to buy evaluation boards and hardware programmers.

The Arduino platform is essentially composed of the following (all of which are open source):

  • C/C++ framework for AVR, ARM, and more (based on Wiring)
  • Device Bootloader
  • Integrated Development Environment (IDE) for Windows, Mac, and Linux

The software framework used to program Arduinos isn't quite strict C/C++ (although it can be if you want), but instead it is a simplified version that removes most of the boilerplate code to keep development as simple as possible. This is in contrast to traditional style embedded programming where quite a bit of initialization logic was needed just to get the device ready for operation. In the past many people just starting out would get frustrated and quit before they could get the device to do anything at all.

The device bootloader is a program that comes pre-programmed on the Arduino microcontrollers and assists with loading your code from memory on startup. When the device is powered on, the first code to run is the bootloader, which fetches your application code from memory and starts its execution. In the case of Arduinos, the bootloader also allows you to load code on to the device via a USB cable instead of a more expensive hardware programmer (or in-system programmer).

The IDE is a desktop application that you use to write, compile, and load code for Arduinos. You can think of it as a glorified text editor (with syntax highlighting) that also compiles and uploads the code for you. Here you can find plenty of example code, configurations, and help documentation to help set up all of the Arduinos you buy. The IDE is not required as you can also write, compile, and load code using the Mac/Linux command line, but this is usually reserved for more advanced users.

Why are Arduinos Useful?

They're Easy to Use:-

As we've already stated, Arduinos are useful in that they greatly lower the barrier of entry in to programming embedded electronics. Thanks to the open source tools available, you can write meaningful applications within minutes instead of hours or days. The learning curve is so much lower now than it used to be, which allows more people to get involved, and in turn expands the industry for everyone.

The Arduino (and Wiring, the programming framework it's based off of) was created with designers, artists, and electronics novices in mind to help encourage a community of all skill levels and to allow them to develop and share their ideas. This opened up a whole new world of interactive art and hobbyist projects that couldn't have been developed otherwise.

They're Open Source:-

Since the Arduino platform is open source and it has allowed millions of people to get involved in embedded electronics, we've seen a huge number of open source projects/code flood sites like Github, which is great for the community.

Not only the code open source, but the hardware is as well. In my opinion, the only thing harder than writing code for microcontrollers is designing the hardware electronics for one. Things are getting better, but there never used to be a whole lot of documentation teaching you how to design a printed circuit board (PCB) board with a microcontroller and peripheral components. Now, there are hundreds of boards, shields, and peripheral components available to use as reference thanks to the open PCB designs.

They're Cheap:-

You can easily find some of the Arduino boards on the internet for around $15, which is far below the hundreds of dollars you used to have to pay for microprocessor/microcontroller evaluation boards. Although hobby electronics did exist, they weren't cheap and their tools were usually pretty poorly made. To get anything higher quality you had to pay top dollar.

How do you use an Arduino?

After installing the Arduino IDE, open it and click the 'New' button to start a new project. This should bring up a new text window with only the "setup()" and "loop()" functions in it. This is the only boilerplate code you need for the sketch.

Now, I won't be going through all of the details here (which I'll save for another post), but the gist of our sketch is that it'll turn on an LED for a half second, turn the LED off for a half second, and continuously repeat. The code should be simple enough to infer what each command is doing. This is about as simple as you can get.

Write the following code in the text window:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

If you just want to verify that your code compiles, but you don't want to upload it to the board, you'll want to click the 'Verify' button. But before you do, make sure you've told the IDE which Arduino board you're using. In my case, I'm using an Nano, so I would tell the IDE this by clicking Tools->Board->Arduino Nano(You can use any Arduino AVR Boards). Now the IDE knows the configuration of my board and how to compile the code.

If you haven't done so already, click 'Verify'. After a second or two you should see text appear in the lower console telling you the sketch "uses 924 bytes (3%) of program storage space" or something similar. Since no errors appeared we know this was accepted by the compiler as valid code.

To upload it to your board, you must first connect the board to your computer via the USB cable. Once connected, you may need to tell the IDE which port the Arduino is on (although most of the time it can find it automatically). You can do this by going to Tools->Port and selecting the port that ends in (Arduino Nano).

Finally, click the 'Upload' button. You'll know the upload worked if you see "Done uploading" just below the text editor window. You should also see the small LED on the board blinking on and off every second.

And that's it, you just wrote code to power a microcontroller!

Conclusion

I hope this cleared some things up on what exactly an Arduino is, and why they're so popular. The platform isn't going away soon, and different variations are popping up all the time, so if you do a bit of searching you'll likely be able to find one that suits your needs.

Comments

Popular Posts