Arduino – Getting Started

I have previously written about device landscape and IoT. I also mentioned briefly Arduino in that post. I am not going to discuss its hardware architecture, and other theory behind it, more than it is needed. In the reference section you will find links you can check if you are new to arduino or want to have some background information.

Arudino is a low-cost, popular Micro-controller platform, which you can program in a C like language. The programs are called called “sketch” and you can write those using Arduino IDE. So, it is a hardware and software platform.

Aurdino has various digital and analog pins, which you can program to interact with environment. For example, we will connect an LED with these pins and then write a program in arduino IDE, once this program is loaded into arduino memory it will blink the LED. Not really a very great program, but the point is that we can interact with hardware, control the power, once we understand this capability, we can almost control any kind of electronic device with it and that’s make it very interesting and powerful.

As this is a getting started post, I will cover some basic topics, however for advanced topic, you can search online or I will post about it as well in future.

In order to start with Arduino, you can purchase it from e.g. amazon or other vendors. I bought the basic starter kit and it comes with Arduino UNO and other interesting useful components like jumper wires, LEDs, RGB LEDs, push buttons etc. The starter kit also includes a nice tutorial, also they put together nice basic projects with details schematic and step by step instructions you can try at your own. You also need to install Arduino software to program this device, you can download it from arduino official website.

Digital and Analog Pins

These pins allows you to interact with environments, they can be connected to sensors, motors, other electronic components etc. You can send 5V to them, You can read attached sensor values from them etc.

Demo

In this demo, I will use Pin 10 for digital and analog write functionality. As you can see that Pin 10 can be used for both purposes. So, I hooked up an LED to Pin 10 (long side to pin 10 and other side to ground GND).

Digital-Write

The following code is sending 5V and 0V to pin 10 (LED). We also introduced a delay and will get the blinking effect.

Sketch

Analog-Write

In the following code, we are not dealing with ON/OFF scenario like the example above. We are now controlling the power to LED in an incrementing order (0-178). So if you upload the following sketch to your arduino board, you will see that LED increase its brightness gradually. You can use same techniques to controller motors or other devices where this functionality is needed.

Sketch

Using a Breadboard

A breadboard enables you to prototype circuits quickly, without having to solder the connections. You can do the above mentioned demos using breadboard as well.

Kindly note, when using breadboard you have to introduce a resistor as well to resist the flow of current, otherwise your LED will burn out and you can damage the board.

RGB LED

  • This is an LED with four leads, it’s actually three LED’s one package. A red, a green and a blue. If you control the levels of the three components colors you can make just about any color in the rainbow. Lots of applications there.
  • They come mostly in 2 versions: Common Anode or Common Cathode.
  • Common Anode uses 5V on the common pin, while Common Cathode connects to ground.

In this example, I used a breadboard and then wrote the following sketch and uploaded it arduino:

Here is the partial code for RGB LED.

Summary

Arduino is a great platform and it is very easy to start with it. In this post, we saw the basics of arduino. A great community is behind it and you will find tons of information online if you need. I am going to use it more in my upcoming IoT related posts. Till next time, Happy Coding.

References


Discover more from Hex Quote

Subscribe to get the latest posts sent to your email.

Discover more from Hex Quote

Subscribe now to keep reading and get access to the full archive.

Continue reading