Art 511: Sensor Based Events / Physical Computing/ Electronics

Spring, 2009   Tentative Schedule, Tutorials,  and Assignments      

(*** Note subject to change)

Spring, 2009   Tu-Th 7-10
Professor Stephen Wilson
539  (Fine Art Annex) phone:  338-2291
swilson@sfsu.edu http://userwww.sfsu.edu/~swilson
More information about Conceptual Information Arts (CIA) Program (http://userwww.sfsu.edu/~infoarts/)

Web Resources:

Class Syllabus  - http://userwww.sfsu.edu/%7Einfoarts/cdmain/elec/a511.physcompsyl.html
Class Schedule & Assignments 
(this document) http://userwww.sfsu.edu/%7Einfoarts/cdmain/elec/511physcomp.schedule.assign2.html
Electronics, Arduino Resources -
http://userwww.sfsu.edu/%7Einfoarts/technical/wilson.electronic.interfaces.html
Books & Articles on interactivity, physical computing, tangible interfaces, ubiquitous, etc -
http://userwww.sfsu.edu/%7Einfoarts/links/vidmot.reading.html
Research in ubiquitous computing -
http://userwww.sfsu.edu/%7Eswilson/emerging/artre440.ubiquitous.html
Links to Artists exploring robotics, kinetics, physical computing - http://userwww.sfsu.edu/~infoarts/links/wilson.artlinks2.html

Electronics Quiz - http://userwww.sfsu.edu/~infoarts/cdmain/elec/511.electronicsquiz/511electronicsquiz5.html
Class wiki- 
http://art511electronic09.wikispaces.com/   (must join via invitation)

Previous class wiki - description of projects, artists  - http://art511electronic07.wikispaces.com/ 



Week 1  Jan  27,29
-Orientation to the Course. Logistics. Preliminary Assignments

**Note R= reading or web work   T= actual lab work     A= art exercises or projects


Ass R1   Read Physical Computing (O'sullivan and Igoe)     pp xv1 - 48 
* introduction, * 1. electricity, * 2. shopping * 3. building circuits
(Be prepared with 2 questions raised by reading  - due week 2  )

Ass R2   Read all course web pages syllabus, electronic resources, book & article list   (due week 2  )

Ass R3  Read introductory material on Arduino site   Ass R4  - Read Articles on Ubiquitous Computing, Pervasive Computing


Week 2  Feb 3,5
- Introduction to setting up the Arduino Board
- Introduction to programming the Arduino
- Introduction to class yahoo group and upload process
- Introduction to computer programming environments

***Tues, Feb 3  2:30 Special CIA guided tour of SFMOMA Art of Participation Show ****
      link to Art of Participation show (also click on related multimedia)
       http://www.sfmoma.org/exhibitions/306

Ass R5  - Read Web-based Introductory Materials on Electronics
Ass R6  - Read Physical Computing chapter 4 (the microcontroller),  chapter 5 (programming - note the syntax of Arduino commands will be slightly different than the languages in the book but logically very similar)   chapter 6 Schematics, Programs, Transducers)   (  due week 3 )

Ass R7   - Artist 1 - Do a web search for an artist who interests you who works with sensors and/or object control.  Upload a link and a short description of the artist you pick to the class wiki. Be prepared to talk about in class -  due week 3   2/6
You will need to join the wiki via the invitation that was sent to you.  If you do not already have a account at wikispace, you will need to set it up.    Post the link to the class wiki.  Pick link to tech artist 1.  Write a short paragraph on why you find that artist interesting.  Copy the link to the artist site. Paste it in the wiki.  You can also include an image of the artist work.  Find an image you like, copy the image location. Go to the Wiki and activate the image upload option.  Paste the url in the external location box.  Double click on the image.  Size it appropriately.
http://art511electronic09.wikispaces.com/ /

For sources, you can use the CIA art & technology artists site- go to kinetics/robotics, activated objects sectiongo to activated objects sectionwilson activated installation list, or any other web sources.

 
Ass  T1 -  Download Arduino Development Software to your computer or to a computer in the lab. Read the instructions carefully and set it up - for example, drivers for the usb may need to be installed..  (links also available on arduino home page  - lab manager may need to install driver part) due week 3   2/6)
  • To get started, follow the instructions for your operating system: Windows, Mac OS X or Linux.
  • Download latest Arduino version available(0011) : Mac OS X (>= 10.3.9): PPC, Intel. Windows. Linux.
  • Read the set up guides  as you set it up- note some USB drivers may be installed
Ass  T2a  Blinking led  - due week 3 )
  • Available on main page tutorials link or at  http://www.arduino.cc/en/Tutorial/BlinkingLED
  • Read the blinking led tutorial
  • use the development environment to write/copy the program
  • hook up the led to the arduino board as explained
  • download the program from computer to arduino
  • run the program
  • troubleshoot
  • be read to explain what each line of the program does
Ass T2b and A1  Blinking led modified with metaphor  - due week 3 )
  • imagine a conceptual mapping of the on & off timing cycles 
  • adjust the timing of the off and on delays
  • upload the program to arduino
  • run it
  • be prepared to talk about your idea and what how the lights and timing metaphorically relate
Ass T2c  Alternating led blinking  - due week 3 )
  • Modify the blinking program to control 2 leds
  • make it turn one on and the other off and then reverse which is on and off and loop
  • you will need to use 2 separate pins so you will need to add those definitions to the program
  • when you use a led in any pin but 13 you will need to add a small resistor in series with led

Ass T2d  Sequential led blinking  - due week 3 )
  • Modify the blinking program to control 3 leds
  • make it turn each one on in sequence (turning off the others)
  • the light will appear to move down the line
  • you will need to use 3 separate pins so you will need to add those definitions to the program
  • when you use a led in any pin but 13 you will need to add a small resistor in series with led



Ass T3    Digital Input and Output (from ITP physcomp labs)  - due week 3 )
  • Study the digital input and output demo program and hookup
  • Modify it so you use different inputs and outputs than the demo
  • hook up the Arduino board in the modified form
  • write the program in modified form
  • upload to Arduino
  • run it
Ass T 4   Learning a computer programming environment


Week 3  Feb 10,12
-Introduction to Electronics  - schematics, components; wire (gauge, solid,stranded, shielded); batteries; resistors (ohms, tolerance, color code);  diode; capacitors (farads); led; transitors (npn pnp, power rating); relay(solid state, electromechanical, no, nc);  phtotcell, switches (spst, dpdt, pole, throw), potentiometer (pot),  darlington transistor array, power supplies (polarity); voltage regulator; other components 
-Introduction to circuits, ohms law (E=IR  I= E/R R=E/I, power(watts  amps x voltage)  - use of the protoboard, multimeter, hook up a basic led switch circuit, measure the voltage, current, resistance,
-  Review Arduino tutorial Analog in and out
-  Demonstration of photocells, thermistor, flex sensor, relays, and transistors
-  Review of programming commands available on Arduino, Demonstration of programming
-  Discussion of artists found on web (ass R7)
-  Discussion of Open source, DIY Culture
-  Bring in a toy or device to hack into for week 4
- Test on symbols & functions of basic components and basic circuits   - due week 4  )

Ass R8  Read articles on Interactivity  - due Week 4
Ass R9  Read web materials on open source, diy  - due Week 4  Ass R10  Read Arduino site materials on the programming language - due Week 4
   - http://www.arduino.cc/en/Reference/HomePage


Ass T5  Create an arduino program  to read a potentiometer  - due Week 4
   - tutorial on reading a potentiometer Tutorial -  Potentiometer  http://www.arduino.cc/en/Tutorial/Potentiometer
 (** note in the tutorial the val variable is set off of the value of the potentiometer - you may need to multiply by some constant number to bring it up a value that makes sense for millisecond delay - for example, if your pot only comes up with a value of 50 then it would be 50 milliseconds - barely perceptible)


Ass T6a,b,c  Read a potentiometer, read a photocell, control a relay.   There are 3 parts to this assignment.

Write an arduino program and set up the board to read a photo cell and control a relay - due Week 4
** This is the first one for which there is not a specific tutorial.  You will have to adapt the previous programs and breadboard hookups to make it work. Take it a step at a time and you will get it.  You have already worked with much of what you need in the previous exercises. Here is the goal for the ultimate circuit:  It will read a photocell (a light sensitive resistor) and it will turn on one led if the light level on the photocell is below a certain level and it will turn on a different led if the light level is brighter and above that level.

 The best way to proceed is to take it in stages, making one change at a time.  If something doesn't work, you will know what part of the changes caused the problem and it will make it easier to troubleshoot.  See the flow charts below.

6a Read a Potentiometer ------------

1. Set up the switch circuit on the breadboard from before (T3).  Also load in that arduino program.  Remember that program turned on one led if the switch was on and another led if it were off.


2. Substitute a pot for the switch in the breadboard.  Remember that switch in T3 went into digital pin 2 and the led's went into pins 3 and 4 with resistors in their  circuits.  The switch circuit was separate from the led circuits.  You are going to substitute a pot circuit for the switch circuit.  It will look similar to the pot circuit you created in T5.   Take the switch and its connecitons out.  Put in a pot.  Remember the 2 sides of it go to positive and negative.  The middle pin goes to analog pin 2  not digital port 2.


3.  Change the sofware to check for the pot readings rather than the switch readings.  You will need to change the variable definitions, setup section, and the loop section.  You will not need a switch pin definition; instead you will need to substitute a variable in which you will store the analog in values.  (Remember the analog in pin produces values from 0-1024 depending on how high the voltage is that it sees in its external circuit.)  You could for example call the variable ana2.  (See line AAA below)  Also you can take out the switchstate variable since this is no more switch, but you will need a variable to hold the analog values - maybe call it val.  (See line BBB below)   In the setup section you don't need to define the switchpin as input.  The analog pins are automatically input.   (See line CCC below)

Change the software to read the pot instead of the switch (similar to code in T5 - you will need to substitute an analog read instead of digital read.  Check the reference or T5 to get the right syntax).  You will need to substitute another variable for switchstate - You already defined a variable (See line DDD below) which you called val in the declare variable section BBB.  This is the variable name you should use.

Change the if statement to check for the analog values instead of the switch being on or off. In the switch example it checks if switchstate==1.  Now you have to check for analog values.  You chnaged line DDD to put the current analog in values into a variable called val.   You have to check what the value of val is and do different things if it is above or below the threshold.  Change line EEE to check if val is greater than that threshold value.  In most computer languages a test for greater than uses the right angle bracket.  Your line will look something like this -- if (val > ???)  {  .  The rest of the lines up to the else will turn one led on and another off if val is bigger than ???. Otherwise the else section activates and reverses the led lighting pattern.   Hopefully you are asking, 'how do I know what ??? is?' How are you going to know what the arduino is seeing at pin 2 as you adjust the pot.  Knowing what values the circuit is producing will be an issue in many of your analog circiits.

//This is the original Switch program from T3 that you can modify

// declare variables:
int switchPin = 2; // digital input pin for a switch AAA
int yellowLedPin = 3; // digital output pin for an LED
int redLedPin = 4; // digital output pin for an LED
int switchState = 0; // the state of the switch
BBB

void setup() {
pinMode(switchPin, INPUT); // set the switch pin to be an input
CCC
pinMode(yellowLedPin, OUTPUT); // set the yellow LED pin to be an output
pinMode(redLedPin, OUTPUT); // set the red LED pin to be an output
// put the begin serial line here FFF
}

void loop() {
// read the switch input: //analog
switchState = digitalRead(switchPin); // DDD read analogin - set val
// GGG send value of val to serial

if (switchState == 1) { //EEE
// if the switch is closed:
digitalWrite(yellowLedPin, HIGH); // turn on the yellow LED
digitalWrite(redLedPin, LOW); // turn off the red LED
}
else {
// if the switch is open:
digitalWrite(yellowLedPin, LOW); // turn off the yellow LED
digitalWrite(redLedPin, HIGH); // turn on the red LED
}
}


Use the serial monitor to determine what values the analog-in pin is reading. Often when developing a program it is useful to get information about what the Arduino is doing.  The Arduino program has a feature where the program you write can send values to the computer to tell you what is going on.  It is called the serial monitor. You need to add a couple of lines to your program to activate this feature. Add a line to output to serial monitor so you can see the values.

(This requires adding this line in the setup part of the program ( "beginSerial(9600);". - line FFF.  This tells the arduino to start communicating with the computer at the 9600 baud speed - bits per second.   Also you would add this line at the end of the loop section.  This  line  acutally sends the value out "Serial.println(val);" - line GGG  Note val would need to be whatever variable name you used for the analog value you read in. Turn on the serial monitor option in the arduino programming environment menu - it will output the values it is getting from the pot. The serial monitor item is the last one of the right in the arduino programming enviornment.  You will see the values appear at the bottom of the screen.  (Ultimately you would turn off the serial monitor and comment out the two lines you added when you are running programs - just because they take up arduino time.  It won't be important in these exercises.)

arduino

6b Add the Photocell ---------------

  Substitute the photocell for the pot.  Use the exact same program you used before but attach the photocell to analog in instead of the pot. You will need to set up a simple circuit called a voltage divider on your breadboard.  The potentiometer had 3 connections. The photocell has only 2.  You will need to add a resistor as a reference so the Arduino can compare the photocell resistance against some other value.  The photocell varies its resistance in accordance with the light that falls on it.  Test it with the multimeter.  You will also need to put a reference resistor in the circuit (since the photocell doesn't have the 3 connections of the pot).  The analog arduino-in pin will read what kind of voltage it is seeing.  If the photocell is less resistance than the reference it will see higher voltage and give higher values.  You will need to experiment what is the best resistor to use.  It should probably be some value in between what the photocell sees when it is bright and when it is dark. Remember your threshold values will need to be adjusted in accordance with room light. Test it.  Use the serial monitor to see how the analog voltage varies as you change the light striking the photocell.

Intuitively think of it this way.  The Arduino analog-in pin goes out looking for voltages.  It wants to know what voltage it is seeing  (between ground (0v) and +5v).  The relative values of resistors in the circuit  determine what voltage the pin thinks it is seeing.  For example,  say the photocell (because of the light level it was exposed to) was reading its value as 200k and assume ??? was a 200k resistor.  What do you think the analog pin would read as its voltage?  It would be near 2.5v right in the middle because the voltage divider would split the voltages. Arduino would read approx 512 - halfway between 0 and 1024 because it converts voltages to digital values in that range. (remember k kilo means 1000s and resistance is measured in ohms)

Now assume a flashlight shines on the photocell.  That would make its resistance lower.  Say it reads its value as 100k ohms.  Lets assume we don't change ??? - it is still 200k.  What do you think the Arduino pin would read.  Well it has 100k between itself and positive and it has 200k between itself and gnd.  Approximately it would think it was 2/3 of the way between gnd and +5 - approximately  3.33v  (2/3x5).   The arduino would read the equivalent digital value 682  (2/3 x 1024).

photocell 



6c Add the relay instead of the leds.---------------
see below


Here are flow charts that show the various parts of the assignment


1. Set up the switch circuit 2.Substitute a pot for the switch


3.Substitute the photocell for the pot 4. Substitute the relay for the led's




6c  cont. Substitue the relay for the led's.  Relays are great devices.  They take low level digital outputs such as those from the Arduino board and control much higher voltages, ac circuits, sound circuits. etc. Relays are the workhorses of much work with physical computing.


Basic explanation of relay principles:   The relay has 2 main functions: 
   1. It isolates the activation circuit -eg from Arduino- from the circuit with the device.  Computer and digital boards have sensitive inputs/outputs.  The things to be controlled (eg lights, motors, etc ) can have higher voltages, curernts etc - even 110 volt AC.  Since the activation circuit is completely separate, it protects the digital device. The device circuit needs its own power, however.
   2. It amplifies the puny 5v signals coming from the digital pins.  Often they don't have much power/current.  With a sensitive relay, even that little signal can control/switch much larger voltages/ power.
  


Basic Explanation of Our Sample Relay:  The sample relay has 3 separate circuits.  One is the activation circuit that is powered by an  digital voltage (for example, the Arduino out pin going low (-)  with the other end connected to Arduino +5.) The other 2 circuits to the two sides are completely separate - you could have lights, motors, whatever with their own power. The computer can send out a puny signal which can switch a much bigger separate circuit.  You should be able to substitute the relay activation pins anywhere you had an led in one of the previous examples.   


Pins on Example Relay:  On the sample relay, pins 1 and 16 (the separated ones at bottom) are the activation circuit.  Remember on another relay they might not be in the same position.  In one of the circuits pin 4 is the common pin.  pin 6 is the normally closed (nc) pin.  (this means even with no activation, it makes a complete circuit with pin 4).  pin 7 is normally open (no) pin.  (this means if there is no activation it will not make a complete circuit with pin 4.  If you put an multimeter set to resistance/ohms it would read infinity because no voltage would be passing)  When pin 1 and 16 get activated (ie a voltage is applied).,  pin 6 and 7 switch their behvaior - pin 4 and 6 become open and pin 4 and 7 become closed/complete.  If you had your circuit attached it would turn on.  The three pins on the other side of the relay mirror the behavior exactly. They are changed with activation but they are not connected to the other side pins at all.  This is called a "double pole"  "double throw" relay  DPDT.  Double throw means it has the normally open and closed options.  Double throw means the two separate circuits are activated.  (Note the pin numbers used show the location of pins in a breadboard circuit - which holes they would plug into.  There are really only 8 pins on this relay.)

relay explain

relay exlain
chip picture


Steps in Replacing Led with Relay
Before you do anything, you need to take cerain steps:

**Discover the pin layouts:   Different relays have different arrangments of pins.  You will not be able to do anything without knowing the pins.  You can get the documentation by reading the identification information off your relay and going on the web.  See the pinout for sample relay in the kit above. (Our example is the Axiom D2n 5v relay.)

**Make sure the relay works - test it without the Arduino. Which are the activation pins? you will need to get that from the documentation.  You should test it by applying voltage to the pins before you attach it to the Arduino. You need to know the activation voltage/power.  Our example has 5v/low power.  Get out your power supply. Set it for 6v.  Polarity will generally not matter for this test.   Set the Multimeter to resistance (ohms).  Hook up the multimeter to the output pins of the relay. You will need to discover which are the output pins.  Use the common and the normally open pin (that is  the pin that is normally not a complete circuit unless the relay is activated. 

**In this example you are using the multimeter as a test circuit.  Eventually you would need to put some circuit in with its own power supply. This test works because the multimeter has its own battery power built in.  ***It is often wise when building circuits to use the multimeter before you put in any other components.  In this case it will  telli you that the circuit is complete/closed because the 2 ends of the multimeter show 0 ohms when there is a continuous circuit (closed).  They show infinity (1 on a digital meter) when there is no complete circuit (open).

**See if the relay works without Arduino. Apply power from your power supply to the activation pins - probably best with alligator clips.  Take the power off the activation pins.    You may hear the relay click when it is activated and again when deactivated.  A simple indicator can be to run the multimeter (set to resistance) through the relay.  It will indicate 1 (infinite, no connection) when the relay is not on and 0 when it is.  (The arduino digital out signal is supposed to be powerful enough to activate this relay.)     -.

**Substitute the relay for the led circuit:   This is typically a good way to work.  Test every component before you hook up the whole circuit.  Does the multimeter work? does the relay work?  Do you understand the relay pins? If yes, you are ready to go.  Hook up the activation pins of the relay to one of the digital out ports of the arduino board. Substitue it for the led in program T3. (You could adapt the blinking led program in T2 or any other program.)  The relay will be hooked only to 1 digital out pin.  Your program will need to turn the pin to one status to turn on the relay when the photocell is beyond your threshold and turn it to other status when the values are below the threshold.  See diagram above the flowcharts. (The arduino digital out signal is supposed to be powerful enough to activate this relay.) 




T6d  --------------
 Consider ways you could change the program and the breadboard hookup.  Consider what kind of events you could orchestrate.

-  One simple line change would change which led went on with high light levels.  What is it?
- How would you adjust the program so you read for 3 light levels instead of just 2?  You would need to add a series of if statements.  How would you need to adjust the led breadboard hook up.
- This program can be very useful in setting up physical computing events - For example, you could have different appliances go on when people shined a flashlight at them.  You could have events activate when people walked  in front of them (ie lowering the light reaching a photocell).  You could  have events that activated when the sun  came up or night arrived.  Please think about how you might use this light sensing capability.



Ass T6e  Attend solder lesson - solder leads to your switch  - due Week 5  
(see electronic resources pages for guides to soldering)

Ass T4 continued - Continue self instruction online tutorials for whatever programming environment you plan to use -



Week 4  Feb 17,19
-  Continue review of programming commands available on Arduino, Demonstration of programming
-  Continue discussion of artists found on web (ass R7)
-  Continue discussion of Open source, DIY Culture  (R9)
-  Discuss readings on interactivity (R8)
-  How to hack into a toy or device
-  Use of relay to control movement among speakers
-  Use of foil and other conductors
-  How to read identity of objects with foil/resistors
-  How to retrofit everyday objects such as opening a box
-  Demonstrate of how to solder
-  How to create and post page
-  Demonstrate simple sensors  - pressure mat, thermistor
-  Test on components, symbols, basic circuits, ohm's law
-  Planning project 1

Ass R10  Read chapters from Information Arts  - due Week 5  Ass A2   Using the skills you have up to this point (simple arduino programming). use of basic electronic components (eg photocell, flexsensor, potentiometer, thermistor, relay, transistor), and hacked or modified found objects,  create an art object/installation that explores ideas of topics that have been discussed such as  tangible computing, activated objects, smart rooms, physical computing, embodiment, gesture, identity, and/or interactivity.  **Note this project should be limited in scope so it can be accomplished in 3 weeks.
   - step 1  Create a proposal page that includes a paragraph explaining your idea and some kind of drawing(s), collage, etc to give the idea. You will need to join the wiki via the invitation that was sent to you.  If you do not already have a account at wikispace, you will need to set it up.
   - step 2  post the proposal to the class wiki- pick the option project 1 proposal  -  due Week 5
 http://art511electronic09.wikispaces.com/
   - step 3  try building prototype hookups and programs out  your project
   - step 4  be prepared to present your proposal in class Feb 20
   - completed project is due   Week 9 

Here are some ideas for forulating an art project.  (Assignment A2)
1.  Come up with an idea that you want to work on - for example, some issue in culture, some objects with strong valence for you, some kinds of formal concerns (lights, sound, motion), that interest you.
2.  Think some way to use the context of physical computing to explore those ideas.
3.  Sensors - What do you want to sense?  Remember you are not restricted to formal sensors.  With some ingenuity you can convert just about any actions in the world into electronic signtals - people presence/absense, motion, moving or manipulating objects, sequences of actions....Anything that can be converted to making or breaking continuity can be seen as a switch. 
4. Actions - What do you want to activate?  Lights, sound, actions of objects.... Remember you are not restricted to formal electronic objects.   For example, lights can illuminate words or images on translucent sheets, the sounds you activate and their relative position can carry cultural meanings. Objects can be retrofitted to represent items of importance to you - for example a toy radio controlled car can be used as the chasis for moving around anything you think that makes sense.
5 Connections - How do you want to link the sensors and the actions.  You would need to program the Arduino to enact those ideas.  (It is possible you might design an object that is not interactive - for example a piece that activates by time passing although I would encourage exploring the sensor - activator link) 


Ass T7a   Write programs to output analog values   -  due Week 5
   - These program will show you how to use digital output pins 9,10,11 in pulse-width mode to simulate variable analog output.  This function will eventually be  useful for functions such as controlling brightness of lights, volume of sound, speed of motors (via control of transistors).  Pulse-width modulation is a technique of quickly turning the pin on and off so it appears to be outputing a fraction of the voltage that the digital pin usually outputs.  It is a way to fake an analog output from a digital pin.
   - Do Arduino ITP tutorial on controlling led brightness with pot  http://itp.nyu.edu/physcomp/Labs/AnalogIn  (don't worry about the monkey example for now.)
   - Do the Arduino tutorial  Dimming 3 LEDs with Pulse-Width Modulation (PWM)  Use the same colored LEDs if the various colors don't work.


Ass T7b  Build a simple circuit to use a transistor to control the brightness of a light.

Transistor background:  A transistor is like a water valve for controlling the flow of electrical current.  The relay can just turn things on and off.  A transistor can let different amounts of current flow - as when you turn a water valve.  In this sense it is an analog (range of values) as opposed to digital (on and off) device.  Think of it as an analog switch that lets more current through the more you push on it.   A small control voltage applied at the pin of the transistor called the base is the method of controlling the larger circuit that needs current trying to go through the transistor.  

Transistors typically have 3 pins called the base, the emitter, and the collector.  As with a relay. a circuit is hooked up to go through the transistor.  For example (in the illustration) a light or a motor might be hooked up to the collector pin and then to positive power supply.  The emitter is hooked up to the negative power supply.  The circuit can be complete only if the transistor allows current flow.  It will not unless some control voltage is applied to the base.  Typically a small resistor is included in the circuit controlling the base in order not to harm the delicate base.

There are two kinds of transistors - NPN  and PNP.  The main differences between these is what kind of control voltage they need to see.  The middle letter is the clue.  NPN needs to see positive (P) voltage.  Also in an NPN the collector is connected in the postive direction and the emitter is conneced in the negative direction.   The TIP120 in your kit is a NPN.   (PNP is exactly opposite - it needs to see negative voltage at the base and the emitter is connected to positive and the collector is connected to negative.) 

Note this circuit does not require the Arduino.  It is powered by an external power supply (similar to what happened in assignment T6C with the relay)

circuit
breadboard


Here are the steps to creating this circuit: 
1.  The best way is to work with a breadboard.  Power the breadboard to create a positive and negative bus (lines of holes at the top).  Use alligator clips to bring + POS and - NEG from one of the connectors that come from your wall adapter.   Steve RANT # 1 - Use your multimeter to check that you know which lines of holes are positive and which are negative.  Confirm your logic by actually testing with multimeter set to volts dc.
2, Then place in your transistor.  Have it span 3 groups of breadboard five holes.  Use a jumper to connect the emitter  to negative.
3. Test the device to be powered.  Steve RANT # 2  - test it directly with power from your power supply before you put it in a circuit.  You need to make sure its working first or you wouldn't ultimately be sure if any problem came from the device or your circuit.
4.  Place in the device to be powered - for example a light or motor.  Use a jumper to bring out the collector pin of transistor to another set of 5 holes.  Connect one lead of your device to the emitter holes.  Connect the other end to the postive voltage supply.
5   Attach a small ohm resistor to the transistor base set of holes and bring its lead out to another set of five holes.
6   Test out the activation of the transistor by linking from those holes to the positive power supply.

Ass T7b  Substitute a potentiometer for the fixed resistor.  You will see you can control the amount of current going through the transistor by changing the value of the pot.  The more resistance, the less positive voltage gets to the base, the less current gets through the transistor, and the dimmer the light.  (you could experiment with any kind of sensor that changes the resistance such as a photoresistor.)  There is no photo or circuit for this but it is similar to assignment earlier where you substituted the photocell for the resistor.


Ass T7c Use Arduino to control a transistor

This circuit is almost exactly like the one above in Ass T7a.  Only two things are different.  Instead of getting positive voltage to the base by touching the positive external power source pin, you output positive voltages from the Arduino.  Remember the PWM (pulse width modulation pins) serve as analog out for the Arduino.  You can output 0 volts to 5 volts (analog write values of 0-255). Pins 9,10,11 have this capability.  The base of the transistor is hooked to Arduino pin 9 (in this example) and the negative ground of the  external power supply is hooked together to get a common ground level.  Those are the only differences.  Then you need to write a program to output analog values.  The light will dim and glow in accordance.  See the illustration below for the hookups.  There is no breadboard photo but you should be able to adapt it.

arduinotransisotr
Sample Arduino program to dim light in steps via analog out


int led = 9; // PWM pin that the transistor base is connected to
// can be 9,10,11

void setup() {
// initialize serial communications at 9600 bps: // not necessary for this
//Serial.begin(9600);
}

void loop() {
analogWrite(led, 255); // PWM the LED with near 5v
delay(500); // wait 500 milliseconds before the next dim

analogWrite(led, 200); // PWM the LED with lower voltage
delay(500); // wait 500 milliseconds before the next dim

analogWrite(led, 150); // PWM the LED with with lower voltage
delay(500); // wait 500 milliseconds before the next dim

analogWrite(led, 50); // PWM the LED with with lower voltage
delay(500); // wait 500 milliseconds before the next dim

}





Note on external power supplies and using Arduino for power.    Once you start using transistors to control higher (current devices you will need to switch the power source either to an external power supply or for medium power  you can use your arduino board.  USB provides a small amount of power to the Arduino.  That is fine for leds and sensitive relays.  It won't be enough to power higher power devices.  You will get error messages such as usb device using too much power and your laptop batteries will drain quickly.  Your external wall wart power supply can be used as external supply for the Arduino.  You will need to do several steps to make this work.  1.  Set your external power supply to 9v.  2.  Make sure its polarity is set to center +.  (you will see the diagrams on the power supply with little + or 1 at the tip image)  3.  Change the jumper on the arduino board to external power supply.  Jumpers are small tabs that connect pins.  It is located between the usb and power input and explained in the guide to the board - sv1 on the diagram.  http://www.arduino.cc/en/Guide/Board.  (switch it back when you are just using usb).   4.  When you do your  exercises be sure to start your analog out with low values and ramp up slowly.  You do not want  to output higher voltages than your device can handle.  For example a bulb from a 3v flashlight will perhaps burn out when fed higher voltages.


Ass T7d    Do Arduino ITP tutorial on controlling high current devices with transistor - Controlling High Current Loads with Transistors    The LEDs allow direct control of brightness - other devices will require a transistor to control current.
   -  You will need to ascertain the pin outs on the transistors we have- what pin is the emitter, collector, base?  The web makes that easier than it used to be.  Look at the transistor - see if you can find the part number.  Once you have that, you can enter it in web search and often get the specifications sheet.  I think the transistors in your kit are tip120 and 2n2222.  You will also need to figure out what bias resistor you must attach to the base (see the transistor tutorials).  You can often use a pot to fine tune this resistor value.
   - Tutorials on Transistors:   Iquana Labs Transistor Tutorial    Mayothi Transistor Tutorial

 


Week 5  Feb 24,26
- Discuss readings from Information Art (R10)
- Discuss proposals for art object (A2)
- Look at tech artists
- Look at analog out examples (T6b)
 Work on Art Project (A2)

 Ass T4 continued - Continue self instruction online tutorials for whatever programming environment you plan to use -


Week 6  March 3,5
- Progress reports on projects - meet with professor
 Work on Art Projects (A2)

Ass T4 continued - Continue self instruction online tutorials for whatever programming environment you plan to use -


Week 7  Mar 10,12
- Progress reports on projects - meet with professor
-  Look at Artists
-- Dicuss Readings

 Work on Art Projects (A2)

Ass T4 continued - Continue self instruction online tutorials for whatever programming environment you plan to use -


Week 8  March 17,19
 
Presentation of art projects (A2)
- Brief introduction of sensors, advanced objects
- Brief iintrodcution computer interface for Arduino board
- Introduce sensors magazine, Electronic Products maagzine

*** possible - Introduction to RFID technology
R11  Read materials on  sensor options
   Sensor Wiki - http://www.sensorwiki.org
   NYU Reports on sensors - http://itp.nyu.edu/physcomp/sensors/Reports/Reports
   Sensors Magaziine
   Electronic Products Magazine    (due Week 10 )

R12a  Read materials on wilson computer interface for Arduino
   Wilson guide to arduino serial interface programs  and demonstration of Director software (due Week 11 )

R12b  Read Physical Computing  book chapter 7 Communicating between computers  chapter 8 Physical Interaction Design, chapter 11 Touch me  (due Week 11  )

R13  Artist 2.  Do a web search for an artist who interests you who works with sensors and/or object control.  Upload a link and a short description of the artist you pick to the class blog. . Be prepared to talk about in class.  Read their statements to understand why they think it is valuable to work with physical objects and environments -  (due week 10 ) Post the link to the class wiki    http://art511electronic09.wikispaces.com/


Ass T4 continued - Continue self instruction online tutorials for whatever programming environment you plan to use -

Week 9  March 24, 26     -------vacation spring break


Week 10  March 31(no classes cesar chavez day) , April 2  (class meets)
- Review of sensor resources  (R11)
- Introduction to advanced options (q prox board, accelerometer, lcd text display, sound synthesis chip?, motor control)
- Introduction how to read a product data sheet
- Discussion of Physical Computing book  chapters (R12b)
- Introduction/ Demonstration to computer interface with Arduino (R12a)
- Presentation of Artist 2 found from web search (R13)

Ass T8  Write a short computer program that turns lights on and off when a person moves the mouse over various images  on the screen.  The goal is to get comfortable with having your media environment communicate with the Arduino board:  Use the Wilson Arduino interface  - due Week 11 
More information on interface at:   Wilson guide to arduino serial interface programs 
Ass T9  Write a short computer program that displays different images or generates specific sounds when people move to particular places (read from a photocell.) or lift up particular objects (read by breaking continuity).  Use the Wilson Arduino interface.  - due Week11
Ass A3   Make either T7 or T8 into a short artistic sketch in which the choices aboukt images and actions relates to an underlying concept


Week 11  April 7,9
- Introduction/ Demonstration to computer interface with Arduino (R12) continued
- Demonstration of how to control a digital movie via physical actions and how to have the movie control physical objects
-Presentation of Artist 2 found from web search (R13)

R14  Read Physical Computing book - chapter 9 sensing movement, chapter,  10 making movement, 12 more communication between devices, 13 controlling sound and light,   due Week11  April 3

Contine work on A3 (T7 and T8)


Week12  April 14,16
- Presentations  of artistic sketches (A3)
-Demonstration of advanced options (q prox board, accelerometer, lcd text display, sound synthesis chip?, motor control)
- Discussion of Physical Computing chapters (R14)
- Demonstration of Web interface to Arduino

R15  Review the section of CIA Art Links focused on telecommunications and the physical
Review artists in telecommunication section - http://userwww.sfsu.edu/%7Einfoarts/links/wilson.artlinks2.html#telecom
or in the web artist site section on 'Arrangements that Use Readings of the Physical World to Affect the Web,  Mixed Realities' http://userwww.sfsu.edu/%7Einfoarts/links/Tele.webart.html
Upload link to artist to class web site in folder "webphysical" in 'links' and be prepared to present in class  due

Ass A4  Develop a proposal for a final project.  It can either be a self contained Arduino installation or a digital media event such as video that integrates sensors and object control.  The project should explore  topics that have been discussed such as  tangible computing, activated objects, smart rooms, physical computing, embodiment, gesture, identity, and/or interactivity. 
  - step 1  Create a proposal page that includes a paragraph explaining your idea and some kind of drawing(s), collage, etc to give the idea.   -  due Week 13  April 17  Post the link to the class wiki    http://art511electronic07.wikispaces.com/
   - step 3  try building prototype hookups and programs out  your project
   - step 4  be prepared to present your proposal in class Feb 20
   - completed project is due   Week 16 


Week 13  April  21,23
- Discuss proposals for final project (A4)
- Present artists who link web and the physical (R15)

 R16  Review Web Sites of Research Groups involved in  tangible computing, ubiquitous, smart rooms etc.  Links to arcicles on Ubiquitous Computing/ Tangible Computing
Pick one project that interests you.  Upload the link and a short description of what you found interesting.  Chose the  "links" option in the class web site. Pick the folder called 'research'
http://groups.yahoo.com/group/art511electronics09
 due week 15
 

 R17  Read Physical Computing book - chapter 14 managing interactions between multiple devices
due week 15 

A4 (cont) Start Arduino programming, computer programing, and prototype construction.
 

Week14  April  28,30
- In class work on final projects
- Individual meetings
 A4 (cont) coninue working on projects

 
Week15  May 5,7
- Present Research Groups  (R16)
- Discuss Physical Computing (r17) multiple devices
- Discussion of Web control // telepresence
- Finish up looking at Tech Artists
-   Work on Final Presentations  - Tech demo due
-    Individual Meetings

Week16  May 12, May 14  
Final Presentations  Tuesday  7-10       A-M last names alphabet - final projects due
Final Presentation   Thursday   7-10    ***** note afternoon special meeting     
N-Z last names alphabet - final projects due
Final Self Evaluation Due - May 19
Self Evaluation Guidelines

rev 1/23/09