Arduino PWM Activities

LED Dimmer

Using the Arduino reference page as a starting point, research the basics of how to use pulse width modulation (PWM) on the Arduinos.

For this activity, you will wire up a potentiometer so it controls the brightness of an LED.

Refer to the Arduino Potentiometer Activities page for further instructions.

Light Sensor

This activity is simply adapted from the LED Dimmer activity, but you will be using the light sensor in place of the potentiometer.

Note that the light sensor input will have to be “scaled” so that when the sensor is covered (dark) the LED will fully lit and when it is uncovered the LED is fully off.

The Design Process

Design Process

This design process model is based on the Ontario 2008 Technological Education curriculum.

From the curriculum:

“Although processes such as this involve a framework of sequential steps, they are typically iterative processes that may require a retracing of steps, diversions to solve specific problems along the way, or even a return to the start of the process if it becomes clear that the situation needs to be clarified and the problem redefined. Problem solvers soon discover that the process calls for an open mind, the freedom to be creative, and a great deal of patience and persistence.”

The graphic above is based on one created by Jackie Griffith. Thanks to Jackie for allowing me to adapt it.

Click here to take a comical look at the design process!

How to Install Apache (on Linux)

Type each of these commands into a terminal window:

sudo apt-get update
sudo apt-get install apache2

To check if Apache is running, enter either or localhost into your web browser.

How To Install KompoZer (on Linux)

(Adapted from

All the commands listed on this page must be entered by copying and pasting into a terminal window.

First, install the dependencies:

sudo apt-get install libatk1.0-0 libc6 libcairo2 libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk2.0-0 libidl0 libnspr4 libnss3 libpango1.0-0 libpng12-0 libstdc++6 libx11-6 libxft2 libxinerama1 libxrender1 libxt6 zlib1g

Then, get the two packages, and install them in the correct order. (Copy and paste each line individually.)

For 32 bit systems:

sudo dpkg -i kompozer-data_0.8~b3.dfsg.1-0.1ubuntu2_all.deb
sudo dpkg -i kompozer_0.8~b3.dfsg.1-0.1ubuntu2_i386.deb

For 64 bit systems:

sudo dpkg -i kompozer-data_0.8~b3.dfsg.1-0.1ubuntu2_all.deb
sudo dpkg -i kompozer_0.8~b3.dfsg.1-0.1ubuntu2_amd64.deb

You will now find KompoZer in the menu.

Arduino Potentiometer Activities


This is a schematic for your circuit:


Some programming basics we will need to know for our program:



Write a program that builds on the basics we learned about in our Blinking LED circuit, this time using the value returned from our sensorValue variable as the “on” delay value (set the “off” delay value to 500). Use pin A0 for the input from the potentiometer.

After you have this assignment completed, call your instructor over to have it marked.

Assignment 2

Add the statement


to your setup() function and the statement


to your loop() function.

Run this program, then call your instructor over for a discussion on how to convert this value to a voltage value. Modify your program accordingly.

After you have this assignment completed, call your instructor over to have it marked.

Arduino Blinking LED Activity

[Lesson Plan]

This overview is a good introduction to the Arduino.

Watch the tutorial and reproduce the experiment that is done in the video.

Do not plug in the USB cable until you have had your circuit checked by the instructor.

Your circuit should look similar to this:


This is a schematic for your circuit:


This is the code you should have:


Extension Activity

Experiment with your program to determine the minimum delay you can have before the LED no longer appears to be blinking? What “rate” does this correspond to?


  • What is an Arduino?
  • What counts as the “input” for this assignment?
  • What is the “output”?
  • If the delay is changed to 500 milliseconds, what is the flashing rate?
  • How would you modify your program to use a different pin as the output?


After you have the experiment completed, call your instructor over to have it marked.

Arduino Empty Program Activity

Enter the following “empty” program into the Arduino editor. Learn how to upload the program into your Arduino.

void setup() {

void loop() {

Save as “Empty Program”.

Arduino Program Structure
(image from the Sparkfun manual – used with permission)