Changes

Jump to: navigation, search

Classes/2010/VIS147A/Lab7

5,918 bytes added, 17:30, 5 January 2010
New page: from Electronic Technologies for Art === From last week === * You should have the basic Blink example running (File->Sketchbook->Examples->Blink) ** This means you have soldered the b...
from [[Electronic Technologies for Art]]

=== From last week ===
* You should have the basic Blink example running (File->Sketchbook->Examples->Blink)
** This means you have soldered the board correctly.
** You can compile and upload files.
* We are going to extend from there.

=== Set up Breadboard ===

# Power from arduino to breadboard:
##connect positive and negative power buses on proto board
#run power, "5V" and "GND" from arduino to breadboard.
[[Image:Power_hookup.png|200px]]
# verify that this worked (with multimeter, or LED test).
[[Image:Verify_power.jpg|200px]]

=== Simple Digital Out ===
# Set up LED on external board, check that it works
[[Image:Led_on_board.png|thumb]]
# Connect the LED to one of your Digital Out pins.(Pins 0-13 on the "Digital" side of your board, by the power light.)
[[Image:d_out_2.png]]

''Basic LED Driver''
# change Blink program (from Sketchbook->Examples->Digital) to output to that pin you connected.
# Compile, upload, and run it.... Does it work?
# try changing the timing (HINT: the <code>delay(1000)</code> statement in Blink example)

=== Simple Digital In ===
[[Image:switch.jpg|thumb]]
[[Image:D_in.png]]

''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.
# Open the button example (File->Sketchbook->Examples->Digital->Button)
# 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 Programming ===
* In the simple blink exampe, this code here:
<code>
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
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.
* What is this actually doing? The <code>HIGH</code> is setting that output pin to High, 1, True, +5V.
* similarity, the <code>LOW</code> is setting that output pin to Low, 0, False, 0V or GND.
* This is where your programmable, internal world of the microcontroller is interfacing with the hardware, LED world of intro to electronics.
* We needed to do some setup first <code>pinMode(ledPin, OUTPUT)</code>
* and then it is a matter of <code>digitalWrite</code> calls.
* Similarly, in the digital_in example above, we do some setup <code>
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
</code>
* And then we read inputs and make outputs with <code>digitalRead</code> and <code>digitalWrite</code> calls.
* 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
delay(1000); // waits for one second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for one second
digitalWrite(ledPin, HIGH); // sets the LED on
delay(500); // waits for half a second second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for one second
</code>
* to get a "long-short-long-short" blinking.
** Try this out.
* As you add more complicated behavior, things are going to get ridiculous very soon, you will have tons of special cases, lines and lines of code. There are more efficient ways to do this...
* What are more efficient ways to do this, use For loops or arrays.

=== Loop (Optional) ===
* Specifically, looping across multiple outputs.
* File->Sketchbook->Examples->Digital->Loop
* Same as single input above, connect multiple LED outputs.
* Compile, upload, and run the loop example.
* Change the behavior of the loop: how about instead of equal on/off timing, change it in some other way.
* Can you make the loop run through a series of meaningful states, rather repeating a simple on/off behavior.
* Differently, with only one output, how could you make a program that changes over time using a loop.

=== Thoughts ===
* The idea of encoding information.
** take a one dimensional output (one light) and communicate valuable information.
** morse code http://en.wikipedia.org/wiki/Morse_code
** Braille (a digital touch encoding), implemented with Servos
* Idea of input and response. Triggering behavior.
* Framing: how does the meaning of a thing change through context. LEDs (or other lights) surround us, everywhere, to indicate all kinds of things.
** "Record" light on a camera. Warning light.
** think about contextualization... if the light is in an empty fuel gauge... warning light... how does its meaning change
** how could you change the meaning through contextualization
** what novel package or "frame" could change the meaning of a thing.

=== Assignment ===
* A quick thought/lab experiment for next week: Extend the example in some way, particularly focusing on the idea of framing.
** This could be through:
*** the addition of multiple different inputs.
*** ...multiple different outputs.
*** ...create a time-varying signal. (code?)
*** change through packaging, framing, context.
*** getting off of the breadboard (or tucking 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, I am interested in the more concept based... having an idea you want to make.

Navigation menu