Changes

Jump to: navigation, search

Classes/2010/VIS147A/Lab7

100 bytes removed, 15:48, 23 February 2010
Activities
=== Setup ===
* FROM LAST WEEK: You should have the basic Blink example running (File->Sketchbook->Examples->Blink). This means you have soldered the board correctly, and you can compile and upload files. We are going to extend from there.
 === Set up Breadboard ===# * Power from arduino to breadboard:##connect . Connect GND and +5 to the positive and negative power buses on proto board#run power, "5V" and "GND" from arduino to the breadboard.
[[Image:Power_hookup.png|200px]]
# * verify that this worked (with multimeter, or LED test).
[[Image:Verify_power.jpg|200px]]
 === Part 1 - Simple Digital Out ===
* Set up an LED on the breadboard with a current limiting resistor.
[[Image:Led_output.png|400px]][[Image:Led_out_on_breadboard.jpg|400px]]
* Change the timing in some more interesting/meaningful 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.
=== Part 2 - Simple Digital In ===
[[Image:switch.jpg|thumb]]
[[Image:D_in.png]]
# Connect your switch circuit to on if the digital I/O pins, and change <code>inputPin</code> in the button program to this number. (Mine is Pin 7)
=== Some Part 3 - Programming ===* In the simple blink exampeexample, this code here:
<code>
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
</code>
* is what creates the behavior: half the time on, half the time off.
* The <code>digitalWrite(ledPin, HIGH)</code> turns on the LED
* <code>digitalWrite(ledPin, LOW)</code> turns off the LED.
* If you ever seen anything in a program, and you want to learn more about what it does, for example digital read, hilight the term, and select Help->Find in reference.
** This will pull up the arduino reference files. There is a lot to be found here. Very useful.
=== So what can we change? ===* You could insert your own code, for instance:
<code>
digitalWrite(ledPin, HIGH); // sets the LED on
* What are more efficient ways to do this, use For loops or arrays.
=== Loop (Optional) Loops ===
* Specifically, looping across multiple outputs.
* File->Sketchbook->Examples->Digital->Loop

Navigation menu