I actually wanna comminucate with two xbee module one to PC and another one to a DC/Stepper motor
I have so many difficulties to write a program which can do it so
I mean I cant write something like readanalog IF it's high check the status if its low there it on to that point else if Low check the status blah blah blah
can u help me with my code
char val; // Data received from the serial port
int motorpin = 37; // Wiring: Connect L293D Pin En1 connected to pin PWM 37
void setup() {
pinMode(motorpin, OUTPUT);
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (Serial.available()) { // If data is available,
val = Serial.read(); // read it and store it in val
if (val == 'H') { // If 'H' was received,
analogWrite(motorpin, 512); // turn the motor on at medium speed
}
else if (val == 'L'){ // If 'L' was received
analogWrite(motorpin, 0); // turn the motor off
}
}
delay(100); // Wait 100 milliseconds for next reading
and i think so many thing should be added to it
like the position of dc motor
Regards