(edit sidebar)
Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

ITP Help Pages
Tom's pcomp site
DanO's pcomp site


Xbee Basics

Tutorials.XbeeBasics History

Hide minor edits - Show changes to output

Changed line 111 from:
>>>>>>>
to:
Changed lines 109-111 from:
%hspace=5 width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]][Screenshot from Tom's Processing Sketch]
to:

%hspace=5 width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]]Screenshot from Tom's Processing Sketch
>>>>>>>
Changed line 109 from:
%hspace=5 width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]]
to:
%hspace=5 width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]][Screenshot from Tom's Processing Sketch]
Changed lines 75-78 from:
[[ http://www.itp.nyu.edu/physcomp/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.

Make sure the sketch is working.
to:
[[ http://www.itp.nyu.edu/physcomp/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing. Make sure the sketch is working.
Changed lines 81-82 from:
Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the [[ PANID page |http://itp.nyu.edu/physcomp/Notes/XBeePANIDs]] Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.
to:
Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the [[ http://itp.nyu.edu/physcomp/Notes/XBeePANIDs| PANID page]] Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.
Changed lines 72-73 from:
%width=400%Attach:CoolTermOptions.png
to:
%width=400%[[Attach:CoolTermOptions.png|Attach:CoolTermOptions.png]]
Changed lines 72-73 from:
Attach:CoolTermOptions.png
to:
%width=400%Attach:CoolTermOptions.png
Changed lines 70-74 from:
Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters.
to:
XBee AT commands are all terminated by a carriage return ('\r', or ASCII 0x0D). If your terminal program allows you to set the string terminator (i.e., the characters sent when you press return), set it to 0x0D. [[http://freeware.the-meiers.org/| CoolTerm]] allows you to do this, and is cross-platform.  Here's a screenshot of the Options panel from CoolTerm, set up to work with XBees:

Attach:CoolTermOptions.png

If you can't use CoolTerm,
Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters.
Changed lines 16-20 from:
You can't use API mode and AT mode at the same time.  You have to choose one or the other for your application.

There are several varieties of XBee radios, the [[http:
//www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#docs| Series 1 radios]] (also called the 802.15.4 OEM Modules), the [[http://www.digi.com/products/wireless/zigbee-mesh/xbee-zb-module.jsp#overview|Series 2 radios]] (also called the ZigBee OEM Modules), and the [[http://www.digi.com/products/wireless/zigbee-mesh/xbee-digimesh-2-4.jsp#overview|Series 2.5 radios]] (also called the DigiMesh Modules). This tutorial deals only with the 802.15.4 modules, which are the easiest to start with.

to:
You generally choose to work in either API mode and AT mode and can't use both at the same time. However the exception is that even radios running in AT mode will still produce API-formatted packets when they receive I/O information from other radios set up as standalone sensors.

There are several varieties of XBee
radios, the [[http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#docs| Series 1 radios]] (also called the 802.15.4 OEM Modules), the [[http://www.digi.com/products/wireless/zigbee-mesh/xbee-zb-module.jsp#overview|Series 2 radios]] (also called the ZigBee OEM Modules). This tutorial deals only with the 802.15.4 modules, which are the easiest to start with.

Changed line 26 from:
*A '''SERIES 1''' XBee or Xbee pro mounted on a [[http://www.sparkfun.com/commerce/product_info.php?products_id=8276  | Breakout board]]
to:
*A '''SERIES 1''' XBee or Xbee Pro mounted on a [[http://www.sparkfun.com/commerce/product_info.php?products_id=8276  | breakout board]]
Changed lines 62-63 from:
Once you've got the XBee module's circuit built and powered,The LED on pin 13 should stay on steadily, and the LED on pin 15 will blink. The former is lit (LED is on) when the module is active. And the later blinks whether the radio is associated with another radio (LED blinking) or not (LED on steadily). Make sure your circuit is connected to your computer and open Processing (you can also use your favorite serial terminal program if that is more familiar).
to:
Once you've got the XBee module's circuit built and powered,The LED on pin 13 should stay on steadily, and the LED on pin 15 will blink. The former is lit (LED is on) when the module is active. And the later blinks when the radio is associated with a network (LED blinking) or not (LED on steadily). Make sure your circuit is connected to your computer and open Processing (you can also use your favorite serial terminal program if that is more familiar).
Changed lines 68-69 from:
The next thing that needs to be done to start using your XBees is to communicate with the radio module serially in order to set its local address and destination address. 
to:
The next thing that needs to be done to start using your XBees, is to communicate with each radio module serially in order to set its local address and destination address. 
Changed lines 86-87 from:
You put the XBee into command mode by typing "+++" (that's plus, plus, plus without the parenthesis, and WITHOUT hitting a return afterward).
to:
You put the XBee into command mode by typing "+++" (that's plus, plus, plus without the quotes, and WITHOUT hitting a return afterward).
Changed lines 122-123 from:
Typing only '''ATID''' and hitting return will output the current address for the xbee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: '''ATID1437'''(or whatever you choose for your PAN) and then hit return.
to:
Typing only '''ATID''' and hitting return will output the current address for the XBee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: '''ATID1437'''(or whatever you choose for your PAN) and then hit return.
Added line 152:
Changed lines 156-162 from:
!!! 2. Upgrading your XBee's firmware using X-CTU

It is often the case that the XBees you have do not have the most recent firmware version. If their firmware is older than verison 10A1, you will not be able to use some common AT commands.  To check the firmware version of your radios, send the following command: '''ATVR\r'''. The radio will respond with the version (i.g. '''10A2'''). If the number is 10A1 or above, you are good to go.  If not, you will need to upgrade the Firmware on your radios using software called X-CTU.




to:



Changed lines 30-33 from:
*Alternatively, you can use the Sparkfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.


to:
*Alternatively, you can use the Sparkfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]], the [[ http://www.newmicros.com/index2.php?url=http%3A%2F%2Fwww.newmicros.com%2Fcgi-bin%2Fstore%2Forder.cgi%3Fform%3Dprod_detail%26part%3DUSB-XBEE-DONGLE-CARRIER |New Micros Xbee dongle]] (more expensive), or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.


Changed lines 154-162 from:
to:
[[<<]]

!!! 2. Upgrading your XBee's firmware using X-CTU

It is often the case that the XBees you have do not have the most recent firmware version. If their firmware is older than verison 10A1, you will not be able to use some common AT commands.  To check the firmware version of your radios, send the following command: '''ATVR\r'''. The radio will respond with the version (i.g. '''10A2'''). If the number is 10A1 or above, you are good to go.  If not, you will need to upgrade the Firmware on your radios using software called X-CTU.



Changed lines 30-33 from:
*Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.


to:
*Alternatively, you can use the Sparkfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.


Changed lines 37-38 from:
!!! 1. Set up a breadboard as shown in the photos below:
to:
!!! 1. Connect an XBee to your personal computer via USB

There are two ways you can do this. You can use a pre-made USB-to-serial board like the Xbee Explorer shown here:

%hspace=5 width=250 alt='xbee explorer' align=top valign=center%http://www.sparkfun.com/commerce/images/products/08687-07-L.jpg

Or you can build your own USB-to-serial adaptor using an XBee breakout board and a USB-to-serial adaptor as shown below:

Set up a breadboard as shown in the photos below:
Changed lines 58-59 from:
The above images show an XBee Module connected to a FTDI USB-to-serial adaptor. The USB adaptor draws power from the USB bus, and the XBee draws power from the adaptor via its 3.3 voltage output.
to:
The above images show an XBee Module connected to a [[http://www.sparkfun.com/commerce/product_info.php?products_id=718|FTDI USB-to-serial adaptor]]. The USB adaptor draws power from the USB bus, and the XBee draws power from the adaptor via its 3.3 voltage output. Note that the adaptor shown is an older model, and the pin positions on newer models have changed.  Check the datasheet on the model you bought, and connect the XBee's transmit pin (TX or DOUT) to the adaptor's receive pin (RX or DIN) and vice versa.
Changed lines 10-11 from:
This tutorial is intended to provide information for getting started with XBees. The first thing that needs to be done to start using your XBees is to communicate with the radio module serially in order to set its local address and destination address.
to:
This tutorial is intended to provide information for getting started with XBee and XBee Pro 802.15.4 modules.
Added lines 32-33:

Added lines 35-36:

Added lines 60-61:
The next thing that needs to be done to start using your XBees is to communicate with the radio module serially in order to set its local address and destination address. 
Added lines 12-20:
XBee radios are 2.4GHz radio transceivers that can be used in two ways. They can be used as pass through data modems, to send serial data from one computer or microcontroller to another. They also have their own digital and analog I/O pins on board that you can use to collect sensor data or to control remote devices. They are addressable, so you can set up a network of several radios as well.

When used as serial radios (called ''serial mode'' or ''AT mode''), they simply take in whatever comes in their serial input and send it out over 2.4GHz radio waves to a destination radio.  When used as standalone devices with sensors or actuators attached (called ''API I/O mode''), they gather data from their inputs and transmit it using their API protocol. They can also receive transmissions that set their output pins using this protocol.

You can't use API mode and AT mode at the same time.  You have to choose one or the other for your application.

There are several varieties of XBee radios, the [[http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#docs| Series 1 radios]] (also called the 802.15.4 OEM Modules), the [[http://www.digi.com/products/wireless/zigbee-mesh/xbee-zb-module.jsp#overview|Series 2 radios]] (also called the ZigBee OEM Modules), and the [[http://www.digi.com/products/wireless/zigbee-mesh/xbee-digimesh-2-4.jsp#overview|Series 2.5 radios]] (also called the DigiMesh Modules). This tutorial deals only with the 802.15.4 modules, which are the easiest to start with.

Changed line 128 from:
to:
[[<<]]
Changed line 103 from:
(:table border=1 width=30% align=right cellspacing=0 :)
to:
(:table border=1 width=30% align=LEFT cellspacing=0 :)
Changed lines 114-123 from:
(:tableend:)


(:table:)
(:cellnr:)
(:cell:)
Radio 1
(:cell:)
+++
(:cell
:)
to:
(:cellnr align=center:)
Changed lines 116-118 from:
(:cell:)
to:
(:cell align=center:)
ATMY 2
(:cellnr align=center
:)
Changed lines 120-131 from:
(:cell:)
ATID 1437
(:cell:)
(:cellnr:)
(:cellnr:)
(:cell:)
Radio 2
(:cell:)
+++
(:cell:)
ATMY 2
(:cell
:)
to:
(:cell align=center:)
Changed lines 122-125 from:
(:cell:)
ATID 1437
(:cell:)
(:cellnr:)
to:
(:cellnr align=center:)
ATID 1437 (YOUR PANID)
(:cell align=center:)
ATID 1437 (YOUR PANID
)
Added line 128:
Added lines 110-113:
(:cellnr align=center:)
+++
(:cell align=center:)
+++
Added lines 103-112:
(:table border=1 width=30% align=right cellspacing=0 :)
(:cellnr colspan=2 align=center:)
'''AT COMMANDS '''
(:cellnr align=center:)
RADIO 1
(:cell align=center:)
Radio 2
(:tableend:)

Added line 69:
(:cell:)
Changed lines 105-110 from:
Radio 1  Radio 2
+++ +++
ATMY 1 ATMY 2
ATDL 2 ATDL 1
ATID 1437 ATID 1437

to:
(:cell:)
Radio 1
(:cell:)
+++
(:cell:)
ATMY 1
(:cell:)
ATDL 2
(:cell:)
ATID 1437
(:cell:)
(:cellnr:)
(:cellnr:)
(:cell:)
Radio 2
(:cell:)
+++
(:cell:)
ATMY 2
(:cell:)
ATDL 1
(:cell:)
ATID 1437
(:cell:)
(:cellnr:)
(:tableend:)

Changed lines 98-99 from:
Typing only ATID and hitting return will output the current address for the xbee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: ATID1437(or whatever you choose for your PAN) and then hit return.
to:
Typing only '''ATID''' and hitting return will output the current address for the xbee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: '''ATID1437'''(or whatever you choose for your PAN) and then hit return.
Deleted lines 101-142:











(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% potValue = 0;  %color=#7e7e7e%// value read from the pot
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  potValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
  %color=#cc6600%analogWrite%%(led, potValue/4);  %color=#7e7e7e%// PWM the LED with the pot value (divided by 4 to fit in a byte)
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(potValue);      %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
 
(:divend:)

When you run this code, the LED should dim up and down as you turn the pot, and the value of the pot should show up in the debugger pane.

!!! Other variable resistors

You can use many different types of variable resistors for analog input.  For example, the pink monkey in the photo below has his arms wired with flex sensors. These sensors change their resistance as they are flexed.  When the monkey's arms move up and down, the values of the flex sensors change the brightness of two LEDs.  The same values could be used to control servo motors, change the frequency on a speaker, or move servo motors. 

%alt='Monski with analog sensors'% [[Attach:monski_analog.JPG|Attach:monski_analog.JPG]]

Changed lines 103-169 from:
(:cellnr colspan=2:)
Monkey's arms schematic:
%alt='Arduino with variable resistors and LED schematic' height=300 %[[Attach:arduino_analog_in2_schem.png|Attach:arduino_analog_in2_schem.png]]
(:cell:)
%alt='Arduino with variable resistors and LED' %[[Attach:bb_dualflex.jpg|Attach:bb_dualflex.jpg]]
(:tableend:)


Here's a closeup on the breadboard:
%alt='Arduino shield with variable resistors and LED' %[[Attach:bb_dualflex_b.jpg|Attach:bb_dualflex_b.jpg]]

The circuit above works for any variable resistor. It's called a '''voltage divider'''. There are two voltage dividers, one on analog in 0 and one on analog in 1.  The fixed resistor in each circuit should have the same order of magnitude as the variable resistor's range.  For example, if you're using a flex sensor with a range of 50 - 100 kilohms, you might use a 47Kohm or a 100Kohm fixed resistor. If you're using a force sensing resistor that goes from inifinity ohms to 10 ohms, but most of its range is between 10Kohms and 10 ohms, you might use a 10Kohm fixed resistor.

The code above assumes you are using a potentiometer, which always gives the full range of analog input, which is 0 to 1023.  Dividing by 4 gives you a range of 0 to 255, which is the full output range of the @@analogWrite()@@ command. The voltage divider circuit, on the other hand, can't give you the full range. The fixed resistor in the circuit limits the range.  You'll need to modify the code.  First find out your range, open the serial monitor and watch the printout as you wave your hand over the photocell.  Note the maximum value and the minimum value. Then you can map the range that the photocell actually gives as input to the range that the LED needs as output. For example, if your photocell gives a range from 400 to 900, you'd do this:

(:div class=code :)
 %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example) to the output range (0-255):
 %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 %color=#cc6600%analogWrite%%(led, brightness);
(:divend:)

Here's an alternate version of the program above for this circuit:

(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% sensorValue = 0;  %color=#7e7e7e%// value read from the analog sensor
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  sensorValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
 
  %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example)
  %color=#7e7e7e%// to the output range (0-255). Change the values 400 and 900 below
  %color=#7e7e7e%// to match the range your analog input gives:
  %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 
  %color=#cc6600%analogWrite%%(led, brightness);  %color=#7e7e7e%// set the LED brightness with the result
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(sensorValue);  %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
(:divend:)


!!! Get creative


''This is a suggestion for the Stupid Pet Trick assignment.  You can do any project you wish as long as it demonstrates your mastery of the lab exercises and good physical interaction. This is just one suggestion.''

Make a luv-o-meter with analog inputs.  A luv-o-meter is a device that measures a person's potential to be a lover, and displays it on a graph of lights.  In gaming arcades, the luv-o-meter is usually a handle that a person grips, and his or her grip is measured either for its strength or its sweatiness. But your luv-o-meter can measure any analog physical quantity that you want, providing you have a sensor for it. Make sure the display is clear, so the participant knows what it means, and make sure it is responsive.








Attach:myImage.jpg
to:
(:cellnr:)
Radio 1  Radio 2
+++ +++
ATMY 1 ATMY 2
ATDL 2 ATDL 1
ATID 1437 ATID 1437

Quit the Processing sketch, and unplug your board from your computer. Next, remove the XBee from the circuit, insert the second XBee and configure it using the same procedure as listed above. Change ATMY to 2, and ATDL to 1. Don't set the radio's destination address to the same value of its source address, or it will talk only to itself.

Changed lines 87-88 from:
Congratulations, you have just programmed your First XBee. Wondering what all of that stuff meant? To program an XBee, you use "AT" commands. Some of the ones we just used are described below:
to:
Congratulations, you have just configured your First XBee. Wondering what all of that stuff meant? To program an XBee, you use "AT" commands. Some of the ones we just used are described below:
Changed lines 90-93 from:
'''ATMY''' my address (the address of the radio you are programming)
'''ATDL''' destination address (the address of the radio that you will be talking to)
'''ATID''' personal area network ID (all the XBee's have a group or Personal Area Network (PAN) ID. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID.
to:
*'''ATMY''' my address (the address of the radio you are programming)
*'''ATDL''' destination address (the address of the radio that you will be talking to)
*'''ATID''' personal area network ID (all the XBee's have a group or Personal Area Network (PAN) ID. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID.
*'''ATRE''' Resets the Xbee to its original settings
*'''ATWR'''    write settings to firmware


Changed lines 87-97 from:










to:
Congratulations, you have just programmed your First XBee. Wondering what all of that stuff meant? To program an XBee, you use "AT" commands. Some of the ones we just used are described below:

Commonly Used XBee "AT" Commands
'''ATMY''' my address (the address of the radio you are programming)
'''ATDL''' destination address (the address of the radio that you will be talking to)
'''ATID''' personal area network ID (all the XBee's have a group or Personal Area Network (PAN) ID. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID.

Typing only ATID and hitting return will output the current address for the xbee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: ATID1437(or whatever you choose for your PAN) and then hit return.

You just did the following commands for Radio 1 (in Column 1). You will now need to do the commands for Radio 2, to program it.











Changed line 83 from:
%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]]
to:
%hspace=5 width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]]
Changed line 83 from:
%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
to:
%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:xbeeSerialTerminal.jpg|Attach:xbeeSerialTerminal.jpg]]
Changed lines 69-80 from:
*Type '''+++ '''
*you should see an '''OK''' response in the top window
*type '''AT''' and see if you get another OK response
*if you don’t you’ve gone back out of command mode, so do''' +++''' again (Xbees will automatically go out of command mode if you wait too long to type something).
*type '''ATID''' to see the current (default) PAN ID
*type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type '''ATID1437''')
*type '''ATID''' to see the current PAN ID again. It should be changed to 1437 now.
*type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type '''ATMY1''' and hit return.
*type '''ATMY''' to see that it has been changed to 1.
*type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: '''ATDL2''' and hit return.
*type '''ATDL''' to see that it has been changed to 2.
*type '''ATCN''' to finish.
to:
#Type '''+++ '''
#you should see an '''OK''' response in the top window
#type '''AT''' and see if you get another OK response
#if you don’t you’ve gone back out of command mode, so do''' +++''' again (Xbees will automatically go out of command mode if you wait too long to type something).
#type '''ATID''' to see the current (default) PAN ID
#type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type '''ATID1437''')
#type '''ATID''' to see the current PAN ID again. It should be changed to 1437 now.
#type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type '''ATMY1''' and hit return.
#type '''ATMY''' to see that it has been changed to 1.
#type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: '''ATDL2''' and hit return.
#type '''ATDL''' to see that it has been changed to 2.
#type '''ATCN''' to finish.
Changed line 69 from:
*Type '''+++'''
to:
*Type '''+++ '''
Changed lines 69-72 from:
*Type +++
*you should see an OK response in the top window
*type AT and see if you get another OK response
*if you don’t you’ve gone back out of command mode, so do +++ again (Xbees will automatically go out of command mode if you wait too long to type something).
to:
*Type '''+++'''
*you should see an '''OK''' response in the top window
*type '''AT''' and see if you get another OK response
*if you don’t you’ve gone back out of command mode, so do''' +++''' again (Xbees will automatically go out of command mode if you wait too long to type something).
Changed lines 73-80 from:
*type %color=red ATID% to see the current (default) PAN ID
*type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type ATID1437)
*type ATID to see the current PAN ID again. It should be changed to 1437 now.
*type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type ATMY1 and hit return.
*type ATMY to see that it has been changed to 1.
*type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: ATDL2 and hit return.
*type ATDL to see that it has been changed to 2.
*type ATCN to finish.
to:
*type '''ATID''' to see the current (default) PAN ID
*type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type '''ATID1437''')
*type '''ATID''' to see the current PAN ID again. It should be changed to 1437 now.
*type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type '''ATMY1''' and hit return.
*type '''ATMY''' to see that it has been changed to 1.
*type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: '''ATDL2''' and hit return.
*type '''ATDL''' to see that it has been changed to 2.
*type '''ATCN''' to finish.
Changed line 73 from:
*type ATID to see the current (default) PAN ID
to:
*type %color=red ATID% to see the current (default) PAN ID
Changed lines 69-80 from:
• Type +++
• you should see an OK response in the top window
• type AT and see if you get another OK response
• if you don’t you’ve gone back out of command mode, so do +++ again (Xbees will automatically go out of command mode if you wait too long to type something).
• type ATID to see the current (default) PAN ID
• type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type ATID1437)
• type ATID to see the current PAN ID again. It should be changed to 1437 now.
• type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type ATMY1 and hit return.
• type ATMY to see that it has been changed to 1.
• type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: ATDL2 and hit return.
• type ATDL to see that it has been changed to 2.
type ATCN to finish.
to:
*Type +++
*you should see an OK response in the top window
*type AT and see if you get another OK response
*if you don’t you’ve gone back out of command mode, so do +++ again (Xbees will automatically go out of command mode if you wait too long to type something).
*type ATID to see the current (default) PAN ID
*type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type ATID1437)
*type ATID to see the current PAN ID again. It should be changed to 1437 now.
*type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type ATMY1 and hit return.
*type ATMY to see that it has been changed to 1.
*type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: ATDL2 and hit return.
*type ATDL to see that it has been changed to 2.
*type ATCN to finish.
Deleted line 69:
Deleted line 70:
Deleted line 71:
Deleted line 72:
Deleted line 73:
Deleted line 74:
Deleted line 75:
Deleted line 76:
Deleted line 77:
Deleted line 78:
Deleted line 79:
Deleted lines 66-96:
(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% potValue = 0;  %color=#7e7e7e%// value read from the pot
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  potValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
  %color=#cc6600%analogWrite%%(led, potValue/4);  %color=#7e7e7e%// PWM the LED with the pot value (divided by 4 to fit in a byte)
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(potValue);      %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
 
(:divend:)

When you run this code, the LED should dim up and down as you turn the pot, and the value of the pot should show up in the debugger pane.

!!! Other variable resistors

You can use many different types of variable resistors for analog input.  For example, the pink monkey in the photo below has his arms wired with flex sensors. These sensors change their resistance as they are flexed.  When the monkey's arms move up and down, the values of the flex sensors change the brightness of two LEDs.  The same values could be used to control servo motors, change the frequency on a speaker, or move servo motors. 

%alt='Monski with analog sensors'% [[Attach:monski_analog.JPG|Attach:monski_analog.JPG]]

Changed lines 68-70 from:
(:cellnr colspan=2:)
Monkey's arms schematic:
%alt='Arduino with variable resistors and LED schematic' height=300 %[[Attach:arduino_analog_in2_schem.png|Attach:arduino_analog_in2_schem.png]]
to:
(:cellnr:)
• Type +++

• you should see an OK response in the top window

• type AT and see if you get another OK response

• if you don’t you’ve gone back out of command mode, so do +++ again (Xbees will automatically go out of command mode if you wait too long to type something).

• type ATID to see the current (default) PAN ID

• type ATID followed by your PAN ID to set it (if your PAN ID is 1437 then you’d type ATID1437)

• type ATID to see the current PAN ID again. It should be changed to 1437 now.

• type ATMY followed by the number you have given to the XBee you are programming. In this case, it would be 1, so type ATMY1 and hit return.

• type ATMY to see that it has been changed to 1.

• type ATDL followed by the number you have given to the other XBee (the XBee you want this XBee to communicate with). In this case, it would be 2, so type: ATDL2 and hit return.

• type ATDL to see that it has been changed to 2.

• type ATCN to finish.
(:cell:)
Changed lines 94-95 from:
%alt='Arduino with variable resistors and LED' %[[Attach:bb_dualflex.jpg|Attach:bb_dualflex.jpg]]
to:
%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
(:cell:)
Changed lines 99-113 from:
Here's a closeup on the breadboard:
%alt='Arduino shield with variable resistors and LED' %[[Attach:bb_dualflex_b.jpg|Attach:bb_dualflex_b.jpg]]

The circuit above works for any variable resistor. It's called a '''voltage divider'''. There are two voltage dividers, one on analog in 0 and one on analog in 1.  The fixed resistor in each circuit should have the same order of magnitude as the variable resistor's range.  For example, if you're using a flex sensor with a range of 50 - 100 kilohms, you might use a 47Kohm or a 100Kohm fixed resistor. If you're using a force sensing resistor that goes from inifinity ohms to 10 ohms, but most of its range is between 10Kohms and 10 ohms, you might use a 10Kohm fixed resistor.

The code above assumes you are using a potentiometer, which always gives the full range of analog input, which is 0 to 1023.  Dividing by 4 gives you a range of 0 to 255, which is the full output range of the @@analogWrite()@@ command. The voltage divider circuit, on the other hand, can't give you the full range. The fixed resistor in the circuit limits the range.  You'll need to modify the code.  First find out your range, open the serial monitor and watch the printout as you wave your hand over the photocell.  Note the maximum value and the minimum value. Then you can map the range that the photocell actually gives as input to the range that the LED needs as output. For example, if your photocell gives a range from 400 to 900, you'd do this:

(:div class=code :)
 %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example) to the output range (0-255):
 %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 %color=#cc6600%analogWrite%%(led, brightness);
(:divend:)

Here's an alternate version of the program above for this circuit:

to:









Changed line 112 from:
 %color=#cc6600%int%% sensorValue = 0;  %color=#7e7e7e%// value read from the analog sensor
to:
 %color=#cc6600%int%% potValue = 0;  %color=#7e7e7e%// value read from the pot
Changed lines 123-127 from:
   sensorValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
to:
   potValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
  %color=#cc6600%analogWrite%%(led, potValue/4);  %color=#7e7e7e%// PWM the LED with the pot value (divided by 4 to fit in a byte)
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(potValue);      %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
Deleted lines 128-131:
   %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example)
  %color=#7e7e7e%// to the output range (0-255). Change the values 400 and 900 below
  %color=#7e7e7e%// to match the range your analog input gives:
  %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
Deleted lines 129-133:
   %color=#cc6600%analogWrite%%(led, brightness);  %color=#7e7e7e%// set the LED brightness with the result
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(sensorValue);  %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
Changed lines 132-192 from:
to:
When you run this code, the LED should dim up and down as you turn the pot, and the value of the pot should show up in the debugger pane.

!!! Other variable resistors

You can use many different types of variable resistors for analog input.  For example, the pink monkey in the photo below has his arms wired with flex sensors. These sensors change their resistance as they are flexed.  When the monkey's arms move up and down, the values of the flex sensors change the brightness of two LEDs.  The same values could be used to control servo motors, change the frequency on a speaker, or move servo motors. 

%alt='Monski with analog sensors'% [[Attach:monski_analog.JPG|Attach:monski_analog.JPG]]

(:table:)
(:cellnr colspan=2:)
Monkey's arms schematic:
%alt='Arduino with variable resistors and LED schematic' height=300 %[[Attach:arduino_analog_in2_schem.png|Attach:arduino_analog_in2_schem.png]]
(:cell:)
%alt='Arduino with variable resistors and LED' %[[Attach:bb_dualflex.jpg|Attach:bb_dualflex.jpg]]
(:tableend:)


Here's a closeup on the breadboard:
%alt='Arduino shield with variable resistors and LED' %[[Attach:bb_dualflex_b.jpg|Attach:bb_dualflex_b.jpg]]

The circuit above works for any variable resistor. It's called a '''voltage divider'''. There are two voltage dividers, one on analog in 0 and one on analog in 1.  The fixed resistor in each circuit should have the same order of magnitude as the variable resistor's range.  For example, if you're using a flex sensor with a range of 50 - 100 kilohms, you might use a 47Kohm or a 100Kohm fixed resistor. If you're using a force sensing resistor that goes from inifinity ohms to 10 ohms, but most of its range is between 10Kohms and 10 ohms, you might use a 10Kohm fixed resistor.

The code above assumes you are using a potentiometer, which always gives the full range of analog input, which is 0 to 1023.  Dividing by 4 gives you a range of 0 to 255, which is the full output range of the @@analogWrite()@@ command. The voltage divider circuit, on the other hand, can't give you the full range. The fixed resistor in the circuit limits the range.  You'll need to modify the code.  First find out your range, open the serial monitor and watch the printout as you wave your hand over the photocell.  Note the maximum value and the minimum value. Then you can map the range that the photocell actually gives as input to the range that the LED needs as output. For example, if your photocell gives a range from 400 to 900, you'd do this:

(:div class=code :)
 %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example) to the output range (0-255):
 %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 %color=#cc6600%analogWrite%%(led, brightness);
(:divend:)

Here's an alternate version of the program above for this circuit:

(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% sensorValue = 0;  %color=#7e7e7e%// value read from the analog sensor
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  sensorValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
 
  %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example)
  %color=#7e7e7e%// to the output range (0-255). Change the values 400 and 900 below
  %color=#7e7e7e%// to match the range your analog input gives:
  %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 
  %color=#cc6600%analogWrite%%(led, brightness);  %color=#7e7e7e%// set the LED brightness with the result
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(sensorValue);  %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
(:divend:)

Changed lines 56-57 from:
Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the [[ PANID page |Page:http://itp.nyu.edu/physcomp/Notes/XBeePANIDs]] Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.
to:
Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the [[ PANID page |http://itp.nyu.edu/physcomp/Notes/XBeePANIDs]] Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.
Changed lines 60-62 from:
Data Mode-- where they transmit and receive data
Command Mode-- talk to the XBee itself to program it etc.
to:
*Data Mode-- where they transmit and receive data
*Command Mode-- talk to the XBee itself to program it etc.
Changed lines 52-55 from:
Now, there is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. This will be your XBee's id and will be used later when you program it. Go ahead and label your second XBee, "2".

%alt='Arduino with potentiometer and LED schematic' height=200 %[[Attach:numberedXbees.jpg|Attach:numberedXbees.jpg]]
to:
There is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. This will be your XBee's id and will be used later when you program it. Go ahead and label your second XBee, "2".

%alt='numbered xbees' height=200 %[[Attach:numberedXbees.jpg|Attach:numberedXbees.jpg]]

Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the [[ PANID page |Page:http://itp.nyu.edu/physcomp/Notes/XBeePANIDs]] Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.

Now we're ready. In order to program the XBee, you first need to put the XBee is in command mode. Xbees essentially have two modes:

Data Mode-- where they transmit and receive data
Command Mode-- talk to the XBee itself to program it etc.

You put the XBee into command mode by typing "+++" (that's plus, plus, plus without the parenthesis, and WITHOUT hitting a return afterward).

Try programming the XBee by clicking on the processing sketch and typing the following commands:

Changed lines 54-55 from:
%alt='Arduino with potentiometer and LED schematic' height=300 %[[Attach:numberedXbees.jpg|Attach:numberedXbees.jpg]]
to:
%alt='Arduino with potentiometer and LED schematic' height=200 %[[Attach:numberedXbees.jpg|Attach:numberedXbees.jpg]]
Changed lines 54-63 from:
Connect a potentiometer to analog in pin 0 of the module, and an LED to digital pin 9:
(
:table:)
(:cellnr colspan=2:)
%alt='Arduino with potentiometer and LED schematic' height=300 %[[Attach:arduino_analog_input_schem
.png|Attach:arduino_analog_input_schem.png]]
(:cell:)
%alt='Arduino with potentiometer and LED' height=300%[[Attach:arduino_pot_led.jpg|Attach:arduino_pot_led.jpg]]
(:tableend:)
!!! Program the Module
Program your Arduino with the following code:

to:
%alt='Arduino with potentiometer and LED schematic' height=300 %[[Attach:numberedXbees.jpg|Attach:numberedXbees.jpg]]
Changed line 31 from:
%hspace=5 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
to:
%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
Changed line 31 from:
%%hspace=5 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
to:
%hspace=5 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
Changed line 31 from:
%%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
to:
%%hspace=5 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
Changed lines 26-29 from:
%lfloat %width=250 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
%%rframe %width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
%width=250 alt='xbee board' align=top valign=center%[[Attach:Xbee_FTDI_schem.jpg|Attach:Xbee_FTDI_schem.jpg]]
to:
(:table:)
(:cellnr:)
%hspace=5 width=250 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
(:cell:)
(:cell:)
%%hspace=5 width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
(:cell:)
(:cell:)
%hspace
=5 width=250 alt='xbee board' align=top valign=center%[[Attach:Xbee_FTDI_schem.jpg|Attach:Xbee_FTDI_schem.jpg]]
(:tableend:)

Changed lines 26-27 from:
%width=250 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
to:
%lfloat %width=250 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
%%rframe %width=250 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
Added line 27:
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:Xbee_FTDI_photo_no_xbee.jpg|Attach:Xbee_FTDI_photo_no_xbee.jpg]]
Changed lines 29-30 from:
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]
to:
Changed line 27 from:
%width=250 alt='xbee board' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]
to:
%width=250 alt='xbee board' align=top valign=center%[[Attach:Xbee_FTDI_schem.jpg|Attach:Xbee_FTDI_schem.jpg]]
Changed lines 26-27 from:
%width=200 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
to:
%width=250 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
%width=250 alt='xbee board' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd
.jpg]]
Changed lines 29-30 from:
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]
to:
Changed line 26 from:
%width=400 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
to:
%width=200 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
Changed line 26 from:
%width=400 alt='xbee on board' align=top valign=center%[[Attach:xbee/06_Xbee_FTDI_photo-3.jpg|Attach:xbee/06_Xbee_FTDI_photo-3.jpg]]
to:
%width=400 alt='xbee on board' align=top valign=center%[[Attach:Xbee_FTDI_photo.jpg|Attach:Xbee_FTDI_photo.jpg]]
Added line 7:
Deleted line 8:
Deleted line 12:
Deleted line 23:
Added line 26:
%width=400 alt='xbee on board' align=top valign=center%[[Attach:xbee/06_Xbee_FTDI_photo-3.jpg|Attach:xbee/06_Xbee_FTDI_photo-3.jpg]]
Changed lines 29-30 from:
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]
to:
Changed lines 47-48 from:
Now, there is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. Since you will probably want to This will be your XBee's id and will be used later when you program it.
to:
Now, there is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. This will be your XBee's id and will be used later when you program it. Go ahead and label your second XBee, "2".
Changed lines 43-44 from:
[[ http://www.itp.nyu.edu/physcomp/Tutorials/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.
to:
[[ http://www.itp.nyu.edu/physcomp/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.
Changed lines 42-43 from:
Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters. [[ http://www.itp.nyu.edu/physcomp/Tutorials/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.
to:
Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters.
[[ http://www.itp.nyu.edu/physcomp/Tutorials/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.

Make sure the sketch is working.

Now, there is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. Since you will probably want to This will be your XBee's id and will be used later when you program it.

Changed lines 40-41 from:
!!! 2.
to:
!!! 2. Configure the XBee Modules Serially

Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters. [[ http://www.itp.nyu.edu/physcomp/Tutorials/uploads/xbeeSerialTerminal.zip | Download it here]] and open it up in Processing.

Added lines 9-13:
!!! Overview
This tutorial is intended to provide information for getting started with XBees. The first thing that needs to be done to start using your XBees is to communicate with the radio module serially in order to set its local address and destination address. 

[[<<]]

Changed lines 26-27 from:
!!! Set up a breadboard as shown in the photos below:
to:
!!! 1. Set up a breadboard as shown in the photos below:
Changed lines 40-41 from:
!!! Add a potentiometer and LED
to:
!!! 2.
Changed lines 29-30 from:
 %color=red%Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.
to:
''' %color=red%Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.'''
Changed lines 29-30 from:
 %color=red% rImportant: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board. %
to:
 %color=red%Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.
Changed lines 29-30 from:
Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.
to:
 %color=red% rImportant: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board. %
Changed lines 7-8 from:

to:
[[<<]]
Changed lines 19-20 from:
to:
[[<<]]
Changed lines 23-31 from:
to:
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]
%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]

The above images show an XBee Module connected to a FTDI USB-to-serial adaptor. The USB adaptor draws power from the USB bus, and the XBee draws power from the adaptor via its 3.3 voltage output.

Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.

Once you've got the XBee module's circuit built and powered,The LED on pin 13 should stay on steadily, and the LED on pin 15 will blink. The former is lit (LED is on) when the module is active. And the later blinks whether the radio is associated with another radio (LED blinking) or not (LED on steadily). Make sure your circuit is connected to your computer and open Processing (you can also use your favorite serial terminal program if that is more familiar).

Changed lines 13-20 from:
#A '''series 1''' XBee or Xbee pro mounted on a [[http://www.sparkfun.com/commerce/product_info.php?products_id=8276  | Breakout board]]
#Wire
#Two LED's
#A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)

#Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.

to:
*A '''SERIES 1''' XBee or Xbee pro mounted on a [[http://www.sparkfun.com/commerce/product_info.php?products_id=8276  | Breakout board]]
*Wire
*Two LED's
*A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)
*Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.

Changed lines 18-20 from:
Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.

to:
#Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.

Changed lines 20-22 from:
%lframe width=100px% [[http://itp.nyu.edu/physcomp/images/labs/breadboard.jpg | http://itp.nyu.edu/physcomp/images/labs/breadboard.jpg"Solderless breadboard"]] | [-Solderless breadboard-]
%lframe width=100px% [[http://itp.nyu.edu/physcomp/images/labs/hookup_wire.jpg | http://itp.nyu.edu/physcomp/images/labs/hookup_wire.jpg"hookup wire"]] | [-22-AWG hookup wire-]

to:
Changed lines 18-19 from:
Alternatively, you can use a
to:
Alternatively, you can use the Spartfun [[http://www.sparkfun.com/commerce/product_info.php?products_id=8687 | Xbee Explorer]] or [[http://www.adafruit.com/index.php?main_page=product_info&products_id=126 | Adafruit models]] which give you direct access to the serial and programming pins on the XBee unit without a breadboard.

%lframe width=100px% [[http://itp.nyu.edu/physcomp/images/labs/breadboard.jpg | http://itp.nyu.edu/physcomp/images/labs/breadboard.jpg"Solderless breadboard"]] | [-Solderless breadboard-]
%lframe width=100px% [[http://itp.nyu.edu/physcomp/images/labs/hookup_wire.jpg | http://itp.nyu.edu/physcomp/images/labs/hookup_wire.jpg"hookup wire"]] | [-22-AWG hookup wire-]

Changed lines 12-13 from:
#FTDI USB-to-serial adaptor
#A
'''series 1''' XBee or Xbee pro mounted on a Breakout board
to:

#A '''series 1''' XBee or Xbee pro mounted on a [[http://www.sparkfun.com/commerce/product_info.php?products_id=8276  | Breakout board]]
Added lines 18-19:
Alternatively, you can use a
Changed lines 6-9 from:

*To set up a PAN id at ITP: please visit the ITP PAN ID page at http://itp.nyu.edu/physcomp/Notes/XBeePANIDs

to:
*To set up a PAN id at ITP: please visit the ITP [[http://itp.nyu.edu/physcomp/Notes/XBeePANIDs | PAN ID page]]

Deleted line 3:
Changed lines 5-6 from:
*For pin mapping, and more than you ever wanted to know: XBee product manual
to:
*For pin mapping, and more than you ever wanted to know: [[http://www.digi.com/products/wireless/point-multipoint/xbee-series1-moduledocs.jsp | XBee product manual]]
Changed lines 5-6 from:
*The notes also include info from Rob Faludi's notes: http://www.faludi.com/itp_coursework/meshnetworking/XBee/
to:
*The notes also include info from Rob Faludi's [[http://www.faludi.com/itp_coursework/meshnetworking/XBee/ | notes]]
Changed lines 3-4 from:
*The following notes borrow heavily from Tom Igoe's, "[[Making Things Talk] http://www.google.com]."
to:
*The following notes borrow heavily from Tom Igoe's, "[[http://www.amazon.com/Making-Things-Talk-Practical-Connecting/dp/0596510519 | Making Things Talk]]."
Changed lines 3-6 from:
*The following notes borrow heavily from Tom Igoe's book, "Making Things Talk." It is highly recommended if you are going to be working with XBees.

*The notes also include info From Rob Faludi's Networked Objects class syllabus, and, definitely check out this site
: http://www.faludi.com/itp_coursework/meshnetworking/XBee/
to:
*The following notes borrow heavily from Tom Igoe's, "[[Making Things Talk] http://www.google.com]."

*The notes also include info from Rob Faludi's notes:
http://www.faludi.com/itp_coursework/meshnetworking/XBee/
Changed lines 17-20 from:
3. Wire
4. Two LED's
5. A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)
to:
#Wire
#Two LED's
#A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)
Changed lines 15-16 from:
1. FTDI USB-to-serial adaptor
2. A '''series 1''' XBee or Xbee pro mounted on a Breakout board
to:
#FTDI USB-to-serial adaptor
#A '''series 1''' XBee or Xbee pro mounted on a Breakout board
Deleted line 0:
Changed lines 11-12 from:
(:toc Table of Contents:)
to:
Changed lines 14-20 from:
For this lab you will need to have the following parts:
FTDI USB-to-serial adaptor
A series 1 XBee mounted on a Breakout board
Wire
Two LED's
A
USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)
to:
'''For this lab you will need to have the following parts:'''
1.
FTDI USB-to-serial adaptor
2. A '''series 1''' XBee or Xbee pro mounted on a Breakout board
3. Wire
4. Two LED's
5.
A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)
Deleted line 1:
Added line 5:
Added line 7:
Added line 9:
Changed lines 17-21 from:

%lframe width=100px% [[Attach:breadboard.jpg | Attach:breadboard.jpg"Solderless breadboard"]] | [-Solderless breadboard-]
%lframe width=100px% [[Attach:hookup_wire.jpg | Attach:hookup_wire.jpg"hookup wire"]] | [-22-AWG hookup wire-]
%lframe width=100px% [[Attach:arduino.jpg | Attach:arduino.jpg"Arduino module"]] | [-Arduino Microcontroller \\
module-
]
to:
FTDI USB-to-serial adaptor
A series 1 XBee mounted on a Breakout board
Wire
Two LED's
A USB-to mini cable (to plug from your computer to the USB-to-serial adaptor)

!!! Set up a breadboard as shown in the photos below:

%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg
]]
Changed lines 28-43 from:
%lframe width=100px valign=center% [[Attach:leds.jpg | Attach:leds.jpg"Light Emiting Diodes"]] | [-Light Emiting Diodes, LED -]
%lframe width=100px valign=center% [[Attach:resistors_220.jpg | Attach:resistors_220.jpg"resistors"]] | [-220-ohm and 10Kohm resistors-]
%lframe width=90px valign=center% [[Attach:potentiometer.jpg | Attach:potentiometer.jpg"potentiometer"]] | [-10Kohm potentiometer-]
Variable resistors
%lframe width=90px valign=center% [[Attach:flex_sensors.jpg | Attach:flex_sensors.jpg"potentiometer"]] | [-Flex sensors\\
(or a different\\
 form of variable resistor)-]
[[<<]]

!!! Prepare the breadboard
Conect power and ground on the breadboard to power and ground from the microcontroller. On the Arduino module, use the 5V and any of the ground connections:

%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]

[[<<]]

to:
Changed lines 1-2 from:
(:XBee Basics:)
to:

Changed lines 5-12 from:
--The following notes borrow heavily from Tom Igoe's book, "Making Things Talk." It is highly recommended if you are going to be working with XBees.

--The notes also include info From Rob Faludi's Networked Objects class syllabus, and, definitely check out this site: http://www.faludi.com/itp_coursework/meshnetworking/XBee/

--For pin mapping, and more than you ever wanted to know: XBee product manual

-- To set up a PAN id at ITP: please visit the ITP PAN ID page at http://itp.nyu.edu/physcomp/Notes/XBeePANIDs
to:
*The following notes borrow heavily from Tom Igoe's book, "Making Things Talk." It is highly recommended if you are going to be working with XBees.
*The notes also include info From Rob Faludi's Networked Objects class syllabus, and, definitely check out this site: http://www.faludi.com/itp_coursework/meshnetworking/XBee/
*For pin mapping, and more than you ever wanted to know: XBee product manual
*To set up a PAN id at ITP: please visit the ITP PAN ID page at http://itp.nyu.edu/physcomp/Notes/XBeePANIDs
Changed lines 1-2 from:

to:
(:XBee Basics:)

!!!Resources

--The following notes borrow heavily from Tom Igoe's book, "Making Things Talk." It is highly recommended if you are going to be working with XBees.

--The notes also include info From Rob Faludi's Networked Objects class syllabus, and, definitely check out this site: http://www.faludi.com/itp_coursework/meshnetworking/XBee/

--For pin mapping, and more than you ever wanted to know: XBee product manual

-- To set up a PAN id at ITP: please visit the ITP PAN ID page at http://itp.nyu.edu/physcomp/Notes/XBeePANIDs

(:toc Table of Contents:)

!!! Parts

For this lab you will need to have the following parts:

%lframe width=100px% [[Attach:breadboard.jpg | Attach:breadboard.jpg"Solderless breadboard"]] | [-Solderless breadboard-]
%lframe width=100px% [[Attach:hookup_wire.jpg | Attach:hookup_wire.jpg"hookup wire"]] | [-22-AWG hookup wire-]
%lframe width=100px% [[Attach:arduino.jpg | Attach:arduino.jpg"Arduino module"]] | [-Arduino Microcontroller \\
module-]
[[<<]]
%lframe width=100px valign=center% [[Attach:leds.jpg | Attach:leds.jpg"Light Emiting Diodes"]] | [-Light Emiting Diodes, LED -]
%lframe width=100px valign=center% [[Attach:resistors_220.jpg | Attach:resistors_220.jpg"resistors"]] | [-220-ohm and 10Kohm resistors-]
%lframe width=90px valign=center% [[Attach:potentiometer.jpg | Attach:potentiometer.jpg"potentiometer"]] | [-10Kohm potentiometer-]
Variable resistors
%lframe width=90px valign=center% [[Attach:flex_sensors.jpg | Attach:flex_sensors.jpg"potentiometer"]] | [-Flex sensors\\
(or a different\\
 form of variable resistor)-]
[[<<]]

!!! Prepare the breadboard
Conect power and ground on the breadboard to power and ground from the microcontroller. On the Arduino module, use the 5V and any of the ground connections:

%width=400 alt='Arduino connected to a breadboard' align=top valign=center%[[Attach:arduino_breadbrd.jpg|Attach:arduino_breadbrd.jpg]]

[[<<]]

!!! Add a potentiometer and LED

Connect a potentiometer to analog in pin 0 of the module, and an LED to digital pin 9:
(:table:)
(:cellnr colspan=2:)
%alt='Arduino with potentiometer and LED schematic' height=300 %[[Attach:arduino_analog_input_schem.png|Attach:arduino_analog_input_schem.png]]
(:cell:)
%alt='Arduino with potentiometer and LED' height=300%[[Attach:arduino_pot_led.jpg|Attach:arduino_pot_led.jpg]]
(:tableend:)
!!! Program the Module
Program your Arduino with the following code:

(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% potValue = 0;  %color=#7e7e7e%// value read from the pot
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  potValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
  %color=#cc6600%analogWrite%%(led, potValue/4);  %color=#7e7e7e%// PWM the LED with the pot value (divided by 4 to fit in a byte)
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(potValue);      %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
 
(:divend:)

When you run this code, the LED should dim up and down as you turn the pot, and the value of the pot should show up in the debugger pane.

!!! Other variable resistors

You can use many different types of variable resistors for analog input.  For example, the pink monkey in the photo below has his arms wired with flex sensors. These sensors change their resistance as they are flexed.  When the monkey's arms move up and down, the values of the flex sensors change the brightness of two LEDs.  The same values could be used to control servo motors, change the frequency on a speaker, or move servo motors. 

%alt='Monski with analog sensors'% [[Attach:monski_analog.JPG|Attach:monski_analog.JPG]]

(:table:)
(:cellnr colspan=2:)
Monkey's arms schematic:
%alt='Arduino with variable resistors and LED schematic' height=300 %[[Attach:arduino_analog_in2_schem.png|Attach:arduino_analog_in2_schem.png]]
(:cell:)
%alt='Arduino with variable resistors and LED' %[[Attach:bb_dualflex.jpg|Attach:bb_dualflex.jpg]]
(:tableend:)


Here's a closeup on the breadboard:
%alt='Arduino shield with variable resistors and LED' %[[Attach:bb_dualflex_b.jpg|Attach:bb_dualflex_b.jpg]]

The circuit above works for any variable resistor. It's called a '''voltage divider'''. There are two voltage dividers, one on analog in 0 and one on analog in 1.  The fixed resistor in each circuit should have the same order of magnitude as the variable resistor's range.  For example, if you're using a flex sensor with a range of 50 - 100 kilohms, you might use a 47Kohm or a 100Kohm fixed resistor. If you're using a force sensing resistor that goes from inifinity ohms to 10 ohms, but most of its range is between 10Kohms and 10 ohms, you might use a 10Kohm fixed resistor.

The code above assumes you are using a potentiometer, which always gives the full range of analog input, which is 0 to 1023.  Dividing by 4 gives you a range of 0 to 255, which is the full output range of the @@analogWrite()@@ command. The voltage divider circuit, on the other hand, can't give you the full range. The fixed resistor in the circuit limits the range.  You'll need to modify the code.  First find out your range, open the serial monitor and watch the printout as you wave your hand over the photocell.  Note the maximum value and the minimum value. Then you can map the range that the photocell actually gives as input to the range that the LED needs as output. For example, if your photocell gives a range from 400 to 900, you'd do this:

(:div class=code :)
 %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example) to the output range (0-255):
 %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 %color=#cc6600%analogWrite%%(led, brightness);
(:divend:)

Here's an alternate version of the program above for this circuit:

(:div class=code :)
 
 %color=#cc6600%int%% potPin = 0;    %color=#7e7e7e%// Analog input pin that the potentiometer is attached to
 %color=#cc6600%int%% sensorValue = 0;  %color=#7e7e7e%// value read from the analog sensor
 %color=#cc6600%int%% led = 9;    %color=#7e7e7e%// PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9
 
 %color=#cc6600%void%% %color=#cc6600%'''setup'''%%() {
  %color=#7e7e7e%// initialize serial communications at 9600 bps:
  %color=#cc6600%Serial%%.%color=#cc6600%begin%%(9600);
  %color=#7e7e7e%// declare the led pin as an output:
  %color=#cc6600%pinMode%%(led, %color=#006699%OUTPUT%%);
 }
 
 %color=#cc6600%void%% %color=#cc6600%'''loop'''%%() {
  sensorValue = %color=#cc6600%analogRead%%(potPin); %color=#7e7e7e%// read the pot value
 
  %color=#7e7e7e%// map the sensor vaue from the input range (400 - 900, for example)
  %color=#7e7e7e%// to the output range (0-255). Change the values 400 and 900 below
  %color=#7e7e7e%// to match the range your analog input gives:
  %color=#cc6600%int%% brightness = %color=#cc6600%map%%(sensorValue, 400, 900, 0, 255);
 
  %color=#cc6600%analogWrite%%(led, brightness);  %color=#7e7e7e%// set the LED brightness with the result
  %color=#cc6600%Serial%%.%color=#cc6600%println%%(sensorValue);  %color=#7e7e7e%// print the pot value back to the debugger pane
  %color=#cc6600%delay%%(10);                    %color=#7e7e7e%// wait 10 milliseconds before the next loop
 }
 
(:divend:)


!!! Get creative


''This is a suggestion for the Stupid Pet Trick assignment.  You can do any project you wish as long as it demonstrates your mastery of the lab exercises and good physical interaction. This is just one suggestion.''

Make a luv-o-meter with analog inputs.  A luv-o-meter is a device that measures a person's potential to be a lover, and displays it on a graph of lights.  In gaming arcades, the luv-o-meter is usually a handle that a person grips, and his or her grip is measured either for its strength or its sweatiness. But your luv-o-meter can measure any analog physical quantity that you want, providing you have a sensor for it. Make sure the display is clear, so the participant knows what it means, and make sure it is responsive.







Added lines 1-3:


Attach:myImage.jpg
  Edit | View | History | Print | Recent Changes | Search Page last modified on March 10, 2010, at 08:23 AM