hi guys.
i currently have this set up
arduino uno + xbee sparkfun shield + xbee
and
xbee + xbee adaptor connected to my PC
code as follows:
#define THRESHOLD 100 // the threshold value
#define SENSOR_TIME 5000 // the amount of time (in milliseconds) that the sensor value has to stay below the threshold (or hold value)
int ledPin = 10; // The digital pin the LED is on
boolean triggered = false; // The "state" of the LED
unsigned long sensor_time; // The last millisecond that the sensor transitioned from being above the threshold and being below it (or the sensor's time stamp)
int sensorPin = 0; // The analog pin the sensor is on
void setup() { // Setup function
pinMode(ledPin, OUTPUT); // Set the pin mode of the LED pin to output
Serial.begin(9600); // Initialize the Serial port to a baud rate of 9600bps
}
void loop() { // Loop function
int sensorValue = analogRead(sensorPin); // Read the value of the sensor
if (sensorValue > THRESHOLD){ // If the value of the sensor is above the threshold value
if (sensor_time == 0) { // If the sensor's time stamp hasn't been updated already
sensor_time = millis(); // store the current millisecond into memory
}
else if (millis() - sensor_time > SENSOR_TIME){ // If the sensor's time stamp subtracted from the current millisecond is greater than the hold value
digitalWrite(ledPin, HIGH); // Set the LED pin high (change to LOW for active low LEDs)
Serial.print("THE BIN IS FULL");
delay(10000);
triggered = true; // Record that the LED has been triggered
}
}
else {
digitalWrite(ledPin, LOW); // Set the LED pin low (change to HIGH for active low LEDs)
if(triggered) { // If the LED has already been triggered
sensor_time = 0; // Reset the sensor's time stamp to 0
triggered = false; // Reset the state of the LEDs triggered value
}
else {
// Do nothing
}
}
}
both my xbees are configured properly.
but my problem i am facing now is that I cant get the xbee at the arduino to send the message to my xbee connected to the computer.
any advice?