Changes

Jump to: navigation, search

Classes/2010/VIS147A/Lab7

1,065 bytes added, 16:49, 23 February 2010
Part 4 - Dot Matrix
=== Part 1 - Simple Digital Out ===
==== Hardware ====
* Set up an LED on the breadboard with a current limiting resistor.
[[Image:Led_output.png|400px]][[Image:Led_out_on_breadboard.jpg|400px]]
* (Slow down the timing if you need to, to measure these).
* Change the timing in some way. (HINT: the <code>delay(1000)</code> statement in the Blink example is what sets the time on and time off). Using what you know, create a different pattern or sequence of activation for the LED. (Massimo Banzi: 'One Circuit, A Thousand Behaviors' p 45-52).
 === Part 2 - Simple Digital In ===[[Image:Digital_in.png|300px]][[Image:switch.jpg|400px]] ''Active High, Normally Open (N.O.) switch''* Set up this circuit on your breadboard, with a switch, +5V, and current limiting resistor to ground. This is a basic digital input.* With your multimeter, check the output voltage of the circuit (V between button and resistor):** V_OUT with the button pressed ____.** V_OUT with the button released ____.* Open the button example (File->Sketchbook->Examples->Digital->Button) in the Arduino software.* Connect your switch circuit to one of the digital I/O pins on your Freeduino, and change <code>inputPin</code> in the button program to correspond to this pin. (Mine is Digital Pin #7)* Compile, upload and run the Button program, verify that it works. You should see your external LED blinking in time with the program. === Part 3 - Programming ======= Digital Out code Code ====
* In the simple blink example, this code
<code>
* This is where your programmable, internal world of the microcontroller is interfacing with the hardware, LED world of intro to electronics.
* Other code: We needed to do some setup first <code>pinMode(ledPin, OUTPUT)</code> so the microcontroller knows whether to use those pins as inputs or outputs. After that, output is simply a matter of <code>digitalWrite</code> calls.
 === Part 2 - Simple Digital In ===== == Hardware ====[[Image:Digital_in.png|300px]][[Image:switch.jpg|400px]] ''Active High, Normally Open (N.O.) switch''* Set up this circuit on your breadboard, with a switch, +5V, and current limiting resistor to ground. This is a basic digital input.* With your multimeter, check the output voltage of the circuit (V between button and resistor):** V_OUT with the button pressed ____.** V_OUT with the button released ____.* Open the button example (File->Sketchbook->Examples->Digital In ->Button) in the Arduino software.* Connect your switch circuit to one of the digital I/O pins on your Freeduino, and change <code>inputPin</code > in the button program to correspond to this pin. (Mine is Digital Pin #7)* Compile, upload and run the Button program, verify that it works. You should see your external LED blinking in time with the program.==== Code ====
* In the Button example above, we do some setup
<code>
* As you desire more complicated behavior, your program is going to get ridiculous very soon, with endless lists of <code>digitalWrite()</code> and <code>if</code> statements. There are more efficient ways to do this... for instance using <code>for</code> loops, <code>switch</code> statements, and arrays.
=== Part 4 3 - Looping over Multiple Digital Outputs For Loop, Iteration ======= Hardware ====* Set up multiple LEDs, multiple 220 Ohm resistors. The ForLoopIteration example (below) expects six or more digital LED outputs similar LEDs, though you could alter the program to those in part 1run with less. (work For instance I set up 3 LEDs in pairs if you would like)the image below.
[[Image:Three_lights.jpg|400px]]
==== Code ====
* Open File->Sketchbook->Examples->Control->ForLoopIteration. This program is similar to the single input above, however with multiple outputs at once. It uses a <code>loop</code> statement to run across a series of pins rather than having to write each output as a separate line.
* Compile, upload, and run the loop example.
* Try changing the value of the <code>timer</code> variable. As the comment in the program says, <code>// The higher the number, the slower the timing.</code>. Conversely, the smaller the value the faster the timing.* Experiment with shorter and shorter timing until At what value of <code>timer</code> do the point at which you are no longer able lights appear to discern individual LEDs turning stay on and offcontinuously? ____. * Remember my multiplexed display example in class, I was technically turning each column on one-at-a-time, but past a point it looked as if the whole smiley-face image was on non-stop. This has to do with the idea of [http://en.wikipedia.org/wiki/Persistence_of_vision persistence of vision]. At what value for <code>timer</code> does it appear that all LEDs are on continually ____.* More examples What does this correspond to in Hertz (Cycles/Second). Calculate this by taking 1 / TIME_ON. (For instance, 1 / 100 ms = 1 / 0.100 s = 10 Hz). ____. * Examples of displays utilizing POV:
** http://www.ladyada.net/make/minipov3/index.html
** bike wheel poke POV http://www.instructables.com/id/SpokePOV%3a-LED-Bike-Wheel-Images/
** http://www.youtube.com/watch?v=mT13ZcpwYtA
* THOUGHTSExtension: Instead of equal on/off timing, can you make the loop run in a different way? Spelling out key presses for a piano keyboard, something like that. Can you make the loop run through a series of meaningful states, rather repeating a simple on/off behavior?* Alternately, with only one output, how could you make a program that changes over time using a loop? === Part 4 - Dot Matrix ===* Working in pairs, set up six or more digital LED outputs. Set these up as a dot matrix display (say 2 X 3 or 3 X 2 or 3 X 3) rather than in a line. Technically you have 13 digital outputs to work with (4 X 3 dot matrix?).* The code and hardware here are the same as driving a single LED, or multiple LEDs in a line. What you are changing is the spatial configuration of the LEDs. Having them arrayed in a box reads differently than having them in a line--now they are "pixels" instead of single lights.* Experiment with code and output to get something to happen. Bounce a ball (tricky!), draw a smiley,... this is an open exercise.
== Homework ==
=== Thoughts ===
* The idea of encoding information.
=== Assignment ===
* A quick thought/lab experiment due in lab next week: extend Extend one of the examples in some way, particularly focusing on the idea of framing(e.g. the idea of establishing a context for your project).
** This could be through:
*** the addition of multiple different inputs.
*** ...multiple different outputs.
*** ...create a time-varying signal. (code?)
*** ...create a simple display. (dot-matrix?)
*** change through packaging, framing, context.
*** getting off of the breadboard (or tucking hiding the breadboard inside of something) how could you change what the LED indicates.
** Some of these are technical challenges, some or more concept based.
** For this assignment (as always!) I am interested in the more concept based approaches, having an idea you want to make. Due in lab next week.
* DUE IN LAB NEXT WEEK. We will look at particular interesting/daring examples at the beginning of that lecture.

Navigation menu