Interacting with the Physical World with Code



Arduino is a generic name used to refer to a range of microcontroller boards originally designed and produced by the company Arduino LLC. Since the design of these boards is open source, they are also produced by several third parties. This post will be based on a specific Arduino board known as the Arduino Uno. This board was chosen for this article because it’s the most popular of the Arduino boards and has tons of information and sample projects to access, making it ideal for taking the first dip into the world of microcontrollers.

What is a microcontroller?

As mentioned earlier, the Arduino is a microcontroller. You can think of a microcontroller simply as an application-specific computer with limited resources. Its application-specific because it is meant for applications like controlling the operation of a microwave or a refrigerator.

Interacting with the physical world

Even though microcontrollers have highly limited resources as far as computational power and memory, they are able to interact directly with physical elements like sensors and actuators through their peripherals, which can be used for input and output. Limiting a microcontroller’s resources also makes it cheap and minimizes the amount of power it requires. The Arduino Uno, for example, goes for about $20 on the official site and requires only 5 volts to power it. The Arduino Uno has 13 pins for digital input and output and 6 pins for analog input and output. Note that some of the 13 digital pins are capable of analog output because they are capable of pulse wave modulation (PWM). These pins have the ‘~’ symbol next to the pin number.


All digital and analog pins can output up to 5V and can receive a maximum of 5V as input. The digital pins can be set to high (5V) or low (0V) in output mode. In addition, they will read high when a voltage above 2.7V is supplied, and low when the supplied voltage is below 0.4V. The analog pins also output up to 5 volts; however, they can also output up to 1,024 levels of voltage from 0V to 5V—that is to say that they produce an output of 0V at level 0, 2.5V (5V/2) at level 512 (1024/2), and 5V at level 1023. The inputs also work with the same levels.

How to use an Arduino

As you may have guessed, Arduinos need to be programmed for use. To make this easy, Arduino provides an Integrated Development Environment (IDE), known as the Arduino IDE, which comes out of the box with tools for programming Arduino boards. As of the time of writing this article, the latest version recommended by the community is version 1.8.5.

This section will show an example of how Arduino programs can be used to turn an LED on and off. This can be done using one of the default examples in the IDE which can blink an LED with the Arduino.

First, connect the LED to pin 13 as shown in the schematic below. The recommended value for the resistor is 1 kilo-ohm.

Then connect the Arduino to your PC via the USB cable. To ensure that the IDE has detected the Arduino, click on Tools, go to the port and click on the option in the sub-menu. Next, select the program (known as a sketch in Arduino terminology) by clicking File -> Basics -> Blink. Finally, click on the compile and upload button (the arrow pointing right) in the top left corner.

You can also find the code below.

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second

Wait a few seconds for the code to compile and upload. You should see the LED blinking soon after it finishes uploading. Congratulations! You’ve completed your Hello World in Arduino. Feel free to try out other examples to experience the amazing world of Arduino.

Stephan is a third-year student at Ashesi pursuing an undergraduate degree in computer engineering. Stephan is passionate about technology and is focused on continuous learning to gain new skills. He has worked in software development, and has worked on IoT projects and designing products for the health sector.


Leave a Comment

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

Skip to toolbar