Title: Week 8 Today
1Week 8Today
- From screen to the physical world.
- Hooking up.(anyone got anything working?)
- Kids toys and mid-term grades
2- From screen to the real world
3Why do I care about this stuff?
- Get out and into the real world!
- Make a robot!
- Build an installation that doesnt need a
computer! - Create a garden that waters itself!
- Plus youll be cool. Check out
- http//cdt.parsons.edu/?qnode/247 - LASER tag
but CDT grads. - http//www.botanicalls.com/ - What? Your plants
are calling you. - http//accad.osu.edu/ayoungs/hydropon.html -
more gardens - http//itp.nyu.edu/show/detail.php?project_id1268
- puppets - Oh - and at the end of the semester were having
a group show I want you folks to have the best
stuff!
4Screen vs. the Real World
- Screen
- Keyboard or mouse
- Separation of response from input
- Wired to the wall
- Computer connection
- Bulky
- Real World
- Direct manipulation
- Response in context of the interaction
- Batteries - wires-free
- Micro-computer wired in
- Can be tiny
5Screen vs. the Real World II
- Screen
- Integrated programming and feedback.
- Debug code only.
- Simple documentation.
- One language.
- Real World
- Programming on the computer and sending code to
the micro-computer - Debug code, connections and electronics.
- Additional steps for good documentation.
- New languages.
6Physical Computing is only
- Sense inputs
- (listen)
- Sense the environment
- temperature
- movement
- pressure
- Create responses
- (speak)
- Do something.
- Water the plant
- Change the lighting
- Screech like a cat
- Process data
- (think)
- via code
- interpret pulses in
- and send out pulses
pulses
pulses
Pulses? Yup. The only thing the micro-computer is
getting in is energy - on or off. That is
basically all it sends out too.
7It all runs on electricity
- Like Water
- Flow
- From High to Low
- High is power, Low is ground.
- Voltage
- Current
- Resistance
- The path of least resistance
- Heat and Burn out
- AC/DC
- Alternating Current
- in the walls
- works over a long distance
- Direct Current
- Simple
- Loses voltage over distance
- Most Physical Computing is run over a short
distance, and most sensors run on low voltage DC
- so this is what we use. - Batteries
- AC - DC converters
8Energy in Parallel or Series
- In Series
- Give energy to each thing, one at a time
- 5 volts
- Turn on light full
- Turn it off
- Turn on next light
- Turn it off
- Turn on third one
- Turn it off
- Each one got full energy.
- In Parallel
- Share energy between all things at the same time.
- 5 volts
- Turn on light A, B and C
- Turn all off.
- Each one got some energy, but less.
9Resistance
- Function
- Reduce the flow of electric current.
- This symbol is used to indicate a resistor in a
circuit diagram. - Units
- Ohms 1000 Ohm 1K Ohm (kiloOhm) 1000K Ohms
1M Ohm (megaOhm). - Types
- Fixed resistors - the amount of resistance does
not change. - Variable resistors - the amount does change.
10Fixed Resistors
- Fixed Resistors
- Precise control
- Many levels of resistance available
- Indicated by color code bands on the resistor (4
or 5 band) - If you can't get the value you need in one,
combine two smaller values You must run them in
SERIES, not in parallel. ('in series' means that
you jump one resistor to the next one, then into
your circuit.)
11Resistance Parallel or Series
- In Series
- Resistance is the sum of each resistor
In Parallel Resistance through each depends on
its value
12- Physical Computing
- (with Arduino)
13Things youll need for class
- The Arduino Board. (40 online, or 30 at NYU
bookstore) - http//www.sparkfun.com/commerce/product_info.php?
products_id666 , http//www.arduino.cc/ - Prototyping board
- This is what you assemble your circuits on. Two
options Jameco or Radio Shack. NYU computer
store sells the Jameco boards, Radio Shack has
the others. - Radio Shack 6" board, part no. 276-174 or the
3 inch version. - Jameco 6" board, part no. 20722 or the 3
inch version. - Resistors, LEDs, and other things
- 1K Ohm Resistors, 1/4 watt -may be available in
the lab - 10K Ohm Resistors, 1/4 watt - probably not
available in the lab - 220 Ohm Resistors, 1/4 watt - probably not
available in the lab - 22K Ohm resistors, 1/4 watt - may be available
in the lab - LED's - available in the lab
- Switch
- Variable resistor. The NYU computer store
carries Flex sensors, which are good fun. Also
consider a potentiometer or solar resistor. - Recommended
- Jumper wire pack from Radio Shack - varied
colors and sizes to fit your breadboard.
14Get started!
- Install the software and USB drivers - you should
have done that already. - Install the Arduino Programming Environment
Download and install the Arduino programming
environment from http//www.arduino.cc/en/Main/Sof
tware. It is based on Processing so it should
look pretty familiar. However, it includes
things specific to the board and the work we'll
be doing, so you need the new environment. There
are PC, unix, old and new Mac versions so you
should be able to find one that will work for
whatever system you use. - http//www.arduino.cc/ to learn more about the
board and what it can do. - Install the USB drivers For Macs this is a
two-step process involving two restarts (look for
the macosx.setup file in your processing library
for serial). For PCs, it's also two steps but
less restarting. For info on how to do it, read
page 16 in the Ardunio booklet.
15Check your engines!
- Plug in the USB cable to both the computer and
the board. - Check to see that a green light comes on your
board. - Open the Arduino software
- Check the serial port and processor version
- For Mac, from the "Tools" menu select "Serial
Port" and select the port that begins with
"/dev/cu.usbserial-". For Windows, see page 18
in the Ardunio booklet. - For both Mac and PC, from the "Tools" menu select
"Microcontroller" and select "Atmega168". You
may need to recheck this again when you restart
your computer.
16On Your Mark!
- The core function of physical computing that we
will be exploring is SENSING the real environment
and INTERPRETING it via code then RESPONDING via
the real world - or a digital world. - To do this we need three things
- Something to SENSE the real world - a sensor
that will send data to our... (a button!) - Code and a mini computer to INTERPRET the
signals (Arduino board) - An actuator, like a motor or a light, that
will RESPOND in the real world, or something on
screen that will take our inputs and respond. (an
LED)
17On Your Mark part II
- To SENSE the real world, you must always looking
for inputs. So a LOOP is needed to constantly be
ready to receive inputs. - Declare variables at the top of our code.
- And setup our initial parameters.
- Basic structure of the code should be
- // variable declaration
- int x
- void setup()
- // put code here to define the pins you use on
the Arduino board. -
- void loop ()
- // put most other code here - anything on-going.
-
18On Your Mark part III
- Pins and the Board
- Your board has a series of places you can plug
SENSORS into to get data in, and plug OUTPUTS
into to get results. These are called PINS. - You need to tell the board which pins you want to
use and what kind of data you will be sending or
receiving through the pin. - Declare a variable (int ledPin 13) This set
the variable ledPin to 13. - Then tell the board how you are using the pin by
declaring the pinMode - pinMode (ledPin, OUTPUT)
- Your board only has 13 pins for input or output,
plus 6 for analog inputs.
19On Your Mark part IV
- LEDs - Light Emitting Diodes
- Like any light, a LED can burn out if you push
too much current through it. - Generally physical computing like we are doing
runs on 5 volts. Most LEDs can only take about 3
volts before they burn out. - Therefore, you usually need to pull down the
current by using a resistor which resists the
flow of current so less gets through to your
LED.Fortunately for this first experiment, pin 13
in the Arduino board, already has a resistor. So
you don't need one - yet. - LEDs are polarized - which means you have to
connect one part of it to ground and the other to
power, and you should not reverse it. There are a
few ways to know which end should go to Power and
which should go to Ground. - Ground - short leg, cathode leg, Anvil shaped
head in LED - Power - long leg, anode leg, flat side of led,
small head in LED
20Get Set!
- Code!
- int ledPin 13 // LED connected
to digital pin 13 - void setup()
-
- pinMode(ledPin, OUTPUT) // sets the
digital pin as output -
- void loop()
-
- 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
21GO!
- Sending Code to your Board
- 1. Connect the board to the computer using the
USB cable. A green light should light on the
board to verify you have connection and power. - 2. RESET the board to clear away the old
program. To do this you press the black button,
and release it. If you have an LED between pin 13
and ground it should flash briefly to alert you
that the board is ready. - 3. Click Verify button to check code and size
(you cannot use more than 14336 bytes). Then
click Upload to I/O board button. Tiny lights on
the board should flash as the data is sent. - 4. Wait a few seconds for your program to start
running.
22Do you have a blinking LED?
- Cool!
- Time to add a push button!
- Then, do the exercises on pages 30-38 of the
Arduino handout. - And
- http//www.arduino.cc/en/Tutorial/KnightRider or
http//www.arduino.cc/en/Tutorial/ShootingStar
Wait! We need sensors for this! Yup. Look in the
DT closet for them or use the ones you bought for
class.
23More on circuits
- Snap Circuits
- Kids toys - but a good lesson in electricity,
control structures and all that. - Do together 1-7, 9, 13, 15
- Your turn 20-22, 32, 47-50, 61, 95, 99
24Homework
- Complete and post your work (description of
project, photo of it, plus code) - Get it all working
- Pushbutton and LED
- 30-38 exercises
- Either NightRider or Shooting Star
- Plus
- Do http//www.arduino.cc/en/Tutorial/Potentiometer
- And read through Structure, control and
comparison, and functions digital, analog and
advanced from http//www.arduino.cc/en/Reference/H
omePage and create a new version of one of your
assignments to include a new control structure.