Was just trying out something crazy and thought of showing carbon monoxide levels as pencil plots (Something like carbon rings on paper) by controlling the translation of a servo attached to a Arduino over wireless x-bee network (See pic below for "Receiver plotter.png").
A MQ7 equipped with an LCD and X-bee on an Arduino will act as the sensor transmitter(Made it successfully and is working. See Pic below-"Transmitter sensor.png") .
The Anaglog voltages are well printed on the LCD(As indicative CO levels) and show the same data on X-CTU's terminal over wireless X-bee network.
(with a "." in fornt of each received data like . 123, .234 etc etc).
this is the Transmitter sensor code:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
sensorValue = analogRead(0); // read analog input pin 0
Serial.println(sensorValue, DEC); // prints the value read
delay(100); // wait 100ms for next reading
lcd.clear(); // Clear the display
lcd.print("CO level:"); // Print some text
I'm receiving values ranging from 120-400(depending on environment I'm in currently).
The only concern is, the servo's not translating as fast with the data change and it even does not change at all sometimes in cases like when the value changes from say 164 - 175. I could just hear a noise from the servo and that's it. I'm using 9gms micro servos but tried with bigger ones also.
I need a noticeable and rapid translations in the servo.
Here's the receiver end's code:
int x = 0;
x = Serial.read()-'0';
Please Help me with the code.
What i'm guessing is may be
1. Buffer problem-But I'm using "Serial.flush();"
2. May be delay can have some effect. Not effected much I tried. (Have to try few more shots.)
3. using "volatile byte" as datatype for the incoming serial data did not make much difference too. (Did not tried it sincerely though) .
Help me here anybody.