28.11.2014 Views

Lab 2: Digital Input and Output with Arduino Boards - Courses

Lab 2: Digital Input and Output with Arduino Boards - Courses

Lab 2: Digital Input and Output with Arduino Boards - Courses

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part 2 – Fading 3 LEDS<br />

3) Extend your circuit so that it includes 3 LEDs according to the diagrams below. (Sorry, all I had<br />

were green wires). Notice Pins 9, 10, <strong>and</strong> 11 are all marked PWM.<br />

4) The following code dims the 3 LEDs according to a pattern. For your convenience, a copy of the<br />

code can be downloaded from the course website. Look at the code <strong>and</strong> make sure you know<br />

what each line does.<br />

Part 3 – Serial Communications<br />

5) Up until now, the <strong>Arduino</strong> board has been operating on autopilot once you’ve uploaded the<br />

program. In this step, you will be using <strong>Arduino</strong>’s Serial Communication feature. The code is<br />

provided here <strong>and</strong> is available on the course webpage. Look at the code <strong>and</strong> make sure you<br />

know what each line does.<br />

Homework (Due Sept 13, 2007)<br />

1) Find a good diffuser for your RGB LEDs (e.g. ping pong ball, Styrofoam, etc).<br />

2) Change the code so that you can control the RGB values <strong>with</strong> multiple key presses. For example,<br />

pressing ‘r’ 5 times will set the brightness to 50% (or brightness = 127) <strong>and</strong> pressing ‘r’ 10 times<br />

will set it to 100% (or brightness = 255).<br />

3) (Optional) Come up <strong>with</strong> other ways of controlling the colors of the LEDs using the keyboard.<br />

Here’s your chance to be creative. You can show off to your friends next week. Example: Read<br />

colors <strong>and</strong> set the appropriate RGB values like “orange” might set r=70%, g=50%, <strong>and</strong> b=0%.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!