Hello,
I want to make an RC car. The overall system is shown in the attachment file. The wireless module is the one here: Cheaper Wireless for Arduino - YouTube.
The thing that I've done differently from the video is that I'm using the Rx and Tx pin of arduino directly (not pin12 in the video) so I have no code like "vv_set_rx_pin(12)". Then, I tested the arduino on the receiver side by plugging its USB port to my computer, so I'll be able to monitor data it received.
However there is no data received at all! Could you please explain?
PS. Here I have the code of the two arduinos
(duty0 = duty cycle of pulsed signal to motor 1: 98.75 is 98.75% for instance)
Sender
float duty0 = 00.00, duty1 = 00.00;
char buffer;
float duty0, duty1;
void setup() {
Serial.begin(9600);
}
void loop() {
duty0 = ((float)(analogRead(0))*100.00 )/1023.00;
duty1 = ((float)(analogRead(1))*100.00 )/1023.00;
if (duty0>=100.00)
duty0 = 99.99;
else if (duty0<= 0.1)
duty0 = 00.00;
if (duty1>=100.00)
duty1 = 99.99;
else if (duty1<= 0.1)
duty1 = 00.00;
//Serial.print("Duty 0 is");
if (duty0<10.00)
Serial.print('0');
Serial.print(duty0);
Serial.print('a');
delay(1000);
//Serial.print("Duty 1 is");
if (duty1<10.00)
Serial.print('0');
Serial.print(duty1);
Serial.print('b');
//Serial.println();
delay(1000);
}
The Receiver
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()>0) {
float value = 00.00;
while (true) {
buffer = Serial.read();
if (buffer =='\n' || buffer =='\r') {
continue;
}
else if (buffer>='0' && buffer<='9') {
value = (value*10) + (float)(buffer-'0');
}
else if (buffer =='.') {
continue;
}
else if (buffer == 'a') {
duty0=value;
break;
}
else if (buffer == 'b') {
duty1 = value;
break;
}
}
}
duty0 /=100.00; //value=value/100
duty1 /=100.00;
Serial.print("Duty0 is");
Serial.println(duty0);
Serial.print("Duty1 is");
Serial.println(duty1);
Serial.println('\n');
}
Regards,
BlackMelon
