I am new to arduino and Xbee these stuff. Trying to send RPM (obtained and calculated by arduino using puulse function) data from arduino to Xbee as analog input to xbee series1.
It seems XBee analog input read a range of 0 volts to 1.2 volts. However, not quite sure how to implement and write the corret code. Following are Arduino code and schematic circuit. Any idea? I really appreciate your help.
int pin = 7; //7
float rpm;
float duration;
float y;
unsigned long val;
float rps;
float read_rpm;
int pin_out=10;
void setup()
{
Serial.begin(9600);
pinMode(pin, INPUT);
pinMode(pin_out,OUTPUT);
}
void loop()
{
val = pulseIn(pin, LOW,70000000);
duration=(float)val/1000000.00;
rps= 1.00/duration;
rpm=60.00*rps;
analogWrite(pin_out,(int)rpm);
Serial.print("RPM=\t");
Serial.print(rpm);
Serial.print("\t rps= \t");
Serial.print(rps);
Serial.print("\t dt=\t");
Serial.println(val);
}
analogWrite()
generates PWM output (oh, PS : except on Mega, but certainly not on Uno), not a purely analog output. And, though I'm not yet familiar with Xbee, I'm not sure you'll achieve analog transmission with it. You could try using some form of DAC, but as suggested below it would be better to send info in digital form.