Arduino #1 — Getting started

Daryl Chan
Aug 26, 2017 · 3 min read

After looking around on r/diy and having tons of “I could do that…” moments, I finally decided to get an Arduino! I’ve played around with the Raspberry Pi’s GPIO pins before but never really gave the Arduino a go.

I was trying to decide whether to get the Uno or Mega but settled for the Uno in the end, figured I didn’t need so many outputs. I got the board itself, a breadboard, a couple of LEDs, a multimeter and some jumper cables.

Front and back
Uploading the Blink example to the board

Making an LED blink

My first idea was to make a simple LED blink, it’s like the Hello World of hardware projects.

I wanted to connect the board’s 5V pin directly to the LED but remembered that you need a current limiting resistor to prevent the LED from burning out.

Used the multimeter to measure the LED’s forward voltage (Vf) — almost 2V
Ohm's Law: 
R = [5V (input) - 2V (LED Vf)] / 20mA (desired LED current)
= 150Ω

The minimum resistance required was 150Ω and so I went with a 220Ω resistor. Wrote the required code and found out that the Arduino programming language is actually a subset of C/C++ and it’s pretty simple.

// Use pin 7
int led = 7;
void setup() {
// Set pin to be output
pinMode(led, OUTPUT);
}
void loop() {
// Set high then delay 500ms
digitalWrite(led, HIGH);
delay(500);
// Set low then delay 500ms
digitalWrite(led, LOW);
delay(500);
}

Uploaded the code to the board and voila!

Did some measurements using the multimeter to make sure that my calculations were correct.

The 220Ω resistor drops almost 3V, that also means…
An almost optimal 2V for the LED!

Then, I started reading about more controlling more LEDs and discovered shift registers and RTC chips. More to come!

)

Daryl Chan

Written by

Aspiring full-stack developer, Computer Science undergraduate, and music junkie ✨

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade