Trouble moving XBee from Uno to Trinket

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
forger
 
Posts: 3
Joined: Sun Apr 26, 2015 12:11 pm

Trouble moving XBee from Uno to Trinket

Post by forger »

Our circuit is a fsr that generates a character and sends it via xbee to the other board and that triggers a LED and haptic motor on another Uno. We had full functionality on the Unos and when we moved to the Trinket(not Pro) it's as though the XBee is reading it's own serial because the affects are happening on the sending board, not the receiving.

On some finals week ish.

We've stripped all of the functions out of the code below and it still acts as though the character is not leaving the sending board.

Code: Select all

#include <SoftwareSerial.h>
SoftwareSerial XBee(0, 1); // RX, TX
int fsrAnalogPin = 2;

void setup()
{
    XBee.begin(9600);
  
  pinMode(1, OUTPUT);
}

void loop() {
  digitalWrite(1, LOW);
  if (analogRead(fsrAnalogPin) > 450) {
    XBee.write('a');
  }
  if (XBee.available()) {
    char c = XBee.read();
    if (c = 'a'){ 
      digitalWrite(1, HIGH);
    }
  }
}
Last edited by adafruit_support_bill on Mon Apr 27, 2015 7:12 pm, edited 1 time in total.
Reason: please use the </> button when submitting code. press </>, then paste your code between the [code] [/code] tags.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trouble moving XBee from Uno to Trinket

Post by adafruit_support_rick »

You need a double '==' on this statement:

Code: Select all

    if (c = 'a'){ 

User avatar
forger
 
Posts: 3
Joined: Sun Apr 26, 2015 12:11 pm

Re: Trouble moving XBee from Uno to Trinket

Post by forger »

Very good, thanks for your help. We now have full functionality!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Trouble moving XBee from Uno to Trinket

Post by adafruit_support_rick »

Cool.

Pro tip: Get in the habit of putting the constant on the left hand side of the conditional. That way the compiler will complain if you forget and use an single '=' instead of a double '=='

Like this:

Code: Select all

    if ('a' = c){   //compiler will complain about this

User avatar
forger
 
Posts: 3
Joined: Sun Apr 26, 2015 12:11 pm

Re: Trouble moving XBee from Uno to Trinket

Post by forger »

Hey thanks for the help!

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”