Digital I/O with Arduino Boards + Diffuser

 

Start Date: Thursday, Sept 10, 2009,  Due Date: Wednesday, Sept 16, 2009

 

Before the Lab

You should have already successfully installed the Arduino environment on your laptop, built the LED circuit, and successfully load/run the “blink” program to make the LED blink. Congratulations!

 

In Lab Exercise

Objective

In this lab, we explore some of the digital features of the Arduino Board. Specifically, we’ll be looking at

1) Pulse Width Modulation (PWM) which “fakes” analog behavior using digital signals

2) Serial communication with the laptop allowing for greater design flexibility.

In exploring these features, we will use Arduino to not just blink a single LED, but to control and fade several LEDs at once.

 

Activities

Part 1 – From Blinking to Fading

1) Start with the LED circuit you built for the “Blinking LED” Assignment. For that assignment, we used pin 13 to control the LED and make it blink. Ardiuno has several pins marked PWM which support Pulse Width Modulation. The example code uses Pin 9, so simply move the controlling wire from Pin 13 to Pin 9.

2) Load the example code from the Arduino Sketchbook (File‐>Sketchbook‐>Examples‐>Analog‐ >Fading). Load this onto the Arduino and watch the LED Fade.

 

 

Part 2 – Fading 3 LEDS

3) Extend your circuit so that it includes 3 LEDs according to the diagrams below. Notice Pins 9, 10, and 11 are all marked PWM.

Here’s your chance to be creative. You can show off to your friends next week. Example: Read colors and set the appropriate RGB values like “orange” might set r=70%, g=50%, and b=0%.

Blinking LED Schematic

 

 

4) The following code dims the 3 LEDs according to a pattern. For your convenience, a copy of the code can be downloaded here (DimmingLEDs.txt). Look at the code and make sure you know what each line does.

 

 

Part 3 – Serial Communications

5) Up until now, the Arduino board has been operating on autopilot once you’ve uploaded the program. In this step, you will be using Arduino’s Serial Communication feature. The code is provided here (serial_led_rgb.txt) and is available on the course webpage. Look at the code and make sure you know what each line does.

 

 

Homework (Due Sept 16, 2009 midnight)

1) Design a good diffuser for your RGB LEDs (e.g. ping pong ball, Styrofoam, etc).

2) Change the code so that you can control the RGB values with multiple key presses. For example,pressing ‘r’ 5 times will set the brightness to 50% (or brightness = 127) and pressing ‘r’ 10 times will set it to 100% (or brightness = 255).

3) (Optional) Come up with other ways of controlling the colors of the LEDs using the keyboard.

 

Click here to post your assignment.

 

You can check out the codes and diffusers created by the tangible07 and 08 students at:

 

http://courses.ischool.berkeley.edu/i290-13/f07/assignments/39.html

 

http://courses.ischool.berkeley.edu/i290-4/f08/?q=node/5