Introduction to Arduino (Actuator)

Install Arduino first. For detail, you can see this post

Arduino 1.0.6


For the details of the installing process, please go to


When you are done with uploading, open Arduino IDE, File/Examples/Basics/Blink and upload. What happens?


make it blink faster

Add second LED on pin 12

Add second LED
Blink them in alternative sequence
1st LED on >> off >> on >> off
1nd LED off >> on >> off >> on

Digital Data VS. Analog Data
When we* say “Digital”, it means 1 or 0, ON or OFF, HIGH or LOW, 0V or 5V… things that has only two states. On the other hand, when we say “Analog”, it has a range of numbers as 0 and 1 and 2 and 3 and 15 and 128 and so on. For example, Arduino’s analog input range is between 0 and 1023, analog output (PWM) range is 0 to 255.

* we as people who are talking about Arduino or microcontroller

Digital pins VS. Analog Pins
The pins on top side in this image are Digital pins, the ones on the bottom right side are Analog pins.
Digital pins can be set as Input or Output, while analog pins are all inputs.
Some digital pins are marked with ~. This means they are also capable of doing PWM, which simulates analog outputs.

Digital Pin, Input and Output
As mentioned earlier, Digital Pins can work as Input or Output.. meaning it can read the Incoming voltage (0V or 5V), or it can set its output voltage to 0V or 5V. It is set as an input by default.

Push Button


inside of a push button

How to connect push button
pull up resistor (10k ohm or bigger)



Analog Read

“A potentiometer, informally a pot, is a three-terminal resistor with a sliding contact that forms an adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat.”
from wikipedia

inside of a potentiometer

Let’s connect the potentiometer to multimeter, and read out the resistance change as you turn the knob. Connect multimeter’s proves to the first pin and the middle pin of the potentiometer.

How to connect with Arduino

We work on this example: Analog Read Serial
Open it from File/Examples/Basic/AnalogReadSerial


Serial Monitor

Analog Input Pins:
it will map input voltages between 0 and 5 volts into integer values between 0 and 1023

Analog Write

The microcontroller’s pins can only output 0V or 5V, and not 1.2V or 2.4V. So, to output voltage between 0V-5V smoothly, in another word to do “fading” affect, it mimics the 1.2V and 2.4V by pulsing 5V and 0V quickly and change the width of the pulsation. This called PWM.

You can read the explanation at Arduino site: Pulse Width Modulation (PWM)

Connection example:


In this first workshop, we go through few exercises to understand how you can use Actuators with Arduino.
Here, I am referring “Actuator” as components that can be actuated by microcontrollers, opposed to “Sensors” that are used to sense the environment and input data into microcontrollers as voltage.

The actuators we use in this workshop are:
– LED (light)
– Servo motor (motion)
– Speaker (sound)
– DC motor (motion, rotation)
– Solenoid (motion)

servo motor

“A servomotor is a rotary actuator that allows for precise control of angular position, velocity and acceleration. It consists of a suitable motor coupled to a sensor for position feedback. It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.”
(from wikipedia>

“As the name suggests, a servomotor is a servomechanism. More specifically, it is a closed-loop servomechanism that uses position feedback to control its motion and final position. The input to its control is some signal, either analogue or digital, representing the position commanded for the output shaft.”
(also from wikipedia)

RC (hobby) Servo motors often comes with 3 colored cables; Black (GND) RED (5V) and Yellow/orange (data). This types of servomotors includes the servomechanism controller inside, which you can send the angle controlling signal from the data line.

Arduino has implemented a library to control the servomotor, called servo library. You can read more about it here

Open the Knob sketch from Examples/Servo/knob
This sketch will allow you to control potentiometer connected to A0 pin to control a servo motor connected to Pin9.

Here is how you connect:

including Library


Now, we can connect small speaker and use TONE library to make music!
Well, it does not make a great sound, but it is a good start.

Open tonePitchFollower from Examples/Digital/tonePitchFollower

This sketch will “play a pitch that changes based on a changing analog input”
Let’s first play sound with potentiometer

Here is how you to connect:


Add Servo motor to make a strange instrument that plays music and moves at the same time

Can we use digital sensors to play sound like keyboard?

Transistor Switch

When you are controlling actuator that needs more than 5V or more than 40mA (this is the maximum current digital pins can supply), you can not directly drive this actuator from the digital pins.

So, idea is that if you could control a switch like this with Arduino

You can do this by using a Transistor as Switch.

or if I write it in schematic way, it is like this

The transistor used here is NPN type one, which by default (0V on base pin) is OFF and it turns ON when you apply voltage on base pin.

Transistor pins
B: Base. You can control ON/OFF state of the transistor switch by applying voltage (i.e. 5V)
C: Collector. On NPN type transistor switch circuit, load (i.e. motor) is above the collector pin
E: Emitter. On NPN type transistor switch circuit, Emitter connects to GND. When voltage is applied to Base pin, Collector and Emitter gets closed (connected).

TIP122 datasheet


A solenoid consists of an electromagnetic coil surrounding a movable metal core, or plunger. When the coil is energized, the magnetic field pulls the core until it’s centered in the coil. Usually, a return spring pulls the core back to its uncentered position when power to the coil is shut off. The movable core provides the mechanical movement.

DC motor:
“When a current passes through the coil wound around a soft iron core, the side of the positive pole is acted upon by an upwards force, while the other side is acted upon by a downward force. According to Fleming’s left hand rule, the forces cause a turning effect on the coil, making it rotate. To make the motor rotate in a constant direction, “direct current” commutators make the current reverse in direction every half a cycle (in a two-pole motor) thus causing the motor to continue to rotate in the same direction.”
from Wikipedia

So, there are not really a direction (+, -) for the motor connection. If you reverse the direction, the motor turns in other direction.


For now, we use 5V from Arduino for the motor power supply, and we skip the resistor between Arduino output pin and transistor’s base pin. The size of the resistor between Transistor’s base pin and GND is 100k ohm.