Actions: * squeezing * stroking * tapping * shaking * dancing * caressing * breathing * pushing
I was pretty stumped about what to do for awhile.. and actually still kind of am... so Tuesday I decided to start off by familiarizing myself with physical computing. It's amazing how little you can bequeath about circuits once you have been away from it for awhile. Anyway so I started off kind of big and tried to re-do my ZIgBee radio - pcomp final project from last go. After becoming frustrated. I back tracked ever further and redid some labs. Yes. I actually redid the Servo go and Analog labs. Haha. So today,(Friday) I entangle confident that I could tackle wireless and actually was able to get it working. (**Rob Faludi thanks again for all of your code and your expertise with Zigbee!**)
So now I undergo my radios working and I can actually hit a change by reversal and undergo an LED light up on the other end.
The Sender works like this: When the sending Zigbee flips its digital switch (pin 12) off and on it converts the 0 and 1 values to a readable ASCII value and sends it out the serial port.
The Receiver works like this: When the receiving Zigbee gets the ASCII determine (in this inspect its a "T") then the Arduino turns on the LED that is connected to connected to pin 11.
****This code is lifted from Rob Faludi*********If you would like to use this label absolutely feel free but be sure to use a different PanID (Your personal area network) My is set to 9999 in this code. Once you undergo selected a PanID so that your radios do not interfere with anyone elses.
// for some reason it seems to help to displace an arbitrary character first //then pause for the guard time before requesting command mode Serial print("X"); delay(1100); // put the XBee in command mode Serial print("+++"); delay(1100); // act for a response from the XBee for 2000 ms or start // over with setup if no valid response comes
if (returnedOK() == 'T') { // if an OK was received then act } else { setup(); // otherwise go back and try setup again }
// set the PAN (personal area communicate) ID number // this example uses 0x3330 but you'll want to choose your own // unique hexadecimal number between 0x0 and 0xFFFE // (say the comma at the end of the command which indicates that another command will follow) Serial create("ATID9999,"); // set the Destination High to 0x0 // to decide 16 bit addressing mode. These addresses can // be assigned and changed by sending commands from a microcontroller Serial print("DH0,"); // set the Destination Low (16 bit address) // this example uses 0x0 for send and 0x1 for acquire but you'll // want to choose your own hexadecimal numbers between 0x0 and 0xFFFE Serial print("DL1234,"); // exit command mode (say that we use Serial printLN here to issue a linefeed that completes the command sequence) Serial println("CN"); // the preceeding commands can also be sent on a hit line desire this using a hit AT dominate with commas: // Serial println("ATID9999,DH0,DL5678,CN"); // the preceeding dominate lie could also be sent as displace commands by reissuing the AT command: // Serial println("ATID3330"); // Serial println("ATDH0"); // Serial println("ATDL1"); // Serial println("ATCN"); // wait for a response from the XBee for 2000 ms or go away // over with setup if no valid response comes if (returnedOK() == 'T') { // if an OK was received then continue } else { setup(); // otherwise go approve and try setup again }
void circle () { // read the switch: thisByte = digitalRead(switchPin); // convert it to a readable ASCII determine send it out the serial port: Serial print(thisByte. DEC);}
cancel blinkLED(int targetPin int numBlinks) { // this function blinks the status LED lighten as many times as requested for (int i=0; i
char returnedOK () { // this answer checks the response on the serial port to see if it was an "OK" or not burn incomingChar[3]; char okString[] = "OK"; char prove = 'n'; int startTime = millis(); while (millis() - startTime
// for some reason it seems to back up to send an arbitrary engrave first //then pause for the guard time before requesting command mode Serial print("X"); decelerate(1100); // put the XBee in command mode Serial print("+++"); delay(1100); // wait for a response from the XBee for 2000 ms or go away // over with setup if no valid response comes
if (returnedOK() == 'T') { // if an OK was received then continue } else { setup(); // otherwise go back and try setup again }
// set the PAN (personal area communicate) ID number // this example uses 0x3330 but you'll want to decide your own // unique hexadecimal number between 0x0 and 0xFFFE // (note the comma at the end of the command which indicates that another command will go) Serial print("ATID9999,"); // set the MY (16 bit address) // this example uses 0x0 for displace and 0x1 for receive but you'll // want to choose your own hexadecimal numbers between 0x0 and 0xFFFE Serial print("MY5678,"); // exit command mode (note that we use Serial printLN here to issue a linefeed that completes the command sequence) Serial println("CN");
// the preceeding commands can also be sent on a single lie like this using a hit AT command with commas: // Serial println("ATID3330,MY1,CN");
// the preceeding command line could also be sent as separate commands by reissuing the AT dominate: // Serial println("ATID3330"); // Serial println("ATMY1"); // Serial println("ATCN");
// wait for a response from the XBee for 2000 ms or start // over with setup if no valid response comes
if (returnedOK() == 'T') { // if an OK was received then continue } else { setup(); // otherwise go back and try setup again }
cancel loop () {// get any incoming data: if (Serial available() > 1) { // construe a byte inByte = Serial read(); // lighten the LED if a 1 has been received } if (inByte == '1') { digitalWrite(outputPin. HIGH); } // douse the LED if anything else was received else { digitalWrite(outputPin. LOW); }}
void blinkLED(int targetPin int numBlinks) { // this function blinks the status LED lighten as many times as requested for (int i=0; i
burn returnedOK () { // this function checks the response on the serial port to see if it was an "OK" or not burn incomingChar[3]; char okString[] = "OK"; char result = 'n'; int startTime = millis(); while (millis() - startTime
Related article:
http://blogblender.faludi.com/2007/09/14/physical-computing-improv/
comments | Add comment | Report as Spam
|