There are 6 force sensors in my device.
Here is my code in Arduino Ide:
int fsrPin1 = 0; // the FSR and 1K pulldown are connected to a0
int fsrPin2 = 1; // the FSR and 1K pulldown are connected to a1
int fsrPin3 = 2; // the FSR and 1K pulldown are connected to a2
int fsrPin4 = 3; // the FSR and 1K pulldown are connected to a3
int fsrPin5 = 4; // the FSR and 1K pulldown are connected to a4
int fsrPin6 = 5; // the FSR and 1K pulldown are connected to a5
int fsrReading1; // the analog reading from the FSR resistor divider
int fsrReading2;
int fsrReading3;
int fsrReading4;
int fsrReading5;
int fsrReading6;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
fsrReading1 = analogRead(fsrPin1);
fsrReading2 = analogRead(fsrPin2);
fsrReading3 = analogRead(fsrPin3);
fsrReading4 = analogRead(fsrPin4);
fsrReading5 = analogRead(fsrPin5);
fsrReading6 = analogRead(fsrPin6);
Serial.print("Sensor 1= ");
Serial.print(fsrReading1); // print the raw analog reading
if (fsrReading1 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading1 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading1 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading1 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
Serial.print("Sensor 2= ");
Serial.print(fsrReading2); // print the raw analog reading*
if (fsrReading2 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading2 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading2 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading2 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
Serial.print("Sensor 3= ");
Serial.print(fsrReading3); // print the raw analog reading
if (fsrReading3 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading3 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading3 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading3 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
Serial.print("Sensor 4= ");
Serial.print(fsrReading4); // print the raw analog reading
if (fsrReading4 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading4 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading4 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading4 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
Serial.print("Sensor 5= ");
Serial.print(fsrReading5); // print the raw analog reading
if (fsrReading5 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading5 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading5 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading5 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
Serial.print("Sensor 6= ");
Serial.print(fsrReading6); // print the raw analog reading
if (fsrReading6 < 10) {
Serial.println(" - No pressure");
} else if (fsrReading6 < 200) {
Serial.println(" - Light touch");
} else if (fsrReading6 < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading6 < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
delay(1000);
}
and I stack the cytron x bee shield on top of the arduino and stack the xbee attena on top of the cytron. Another x bee i stack on top of the xbee USB adapter and connect to the PC. But i have no idea on how to read data from the xbee USB adapter, although i already configured both xbee on XCTU and both xbee can communicate together, someone Please Help!