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.

From the relevant page on the Arduino website you should be able to find enough information to wire and program this activity yourself.

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.

Arduino Potentiometer Activities

Background

This is a schematic for your circuit:

null

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

null

Assignment

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 delay value. Use pin A0 for the input from the potentiometer.

Note!

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

Assignment 2

Add the statement

Serial.begin(9600);

to your setup() function and the statement

Serial.println(sensorValue);

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.

Note!

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.

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

Your circuit should look similar to this:

null

This is a schematic for your circuit:

null

This is the code you should have:

null

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?

Questions

  • 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?

Note!

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)