hello,
i try to build an rc car using arduinos and 433Mhz module for the direction the car use a servomotor, in the code i used radiohead RH_ASK.h for the 433 modules and Servo.h to drive the servo, after compiling the ide is show an error code after i searched on google i found that the RH_ASK.h and Servo.h have a conflict, they both use timer1 so i desired to not use servo.h here is my code :
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
pinMode(9, OUTPUT);
}
void loop()
{
int b;
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen))
{
if((int)buf[1]==66)
{
b=(int)buf[0];
d=map(b, 0, 255, 120, 180);
Serial.println(d*10);
}
}
digitalWrite(9, HIGH);
delayMicroseconds(d*10);
digitalWrite(9, LOW);
delayMicroseconds(20000-d*10);
}
the receiver work fine, i get the correct value on the serial monitor but the servo go crazy, and when i test the servo code alone it work :
void setup(){
pinMode(9, OUTPUT);
void loop(){
int d=150;
digitalWrite(9, HIGH);
delayMicroseconds(d*10);
digitalWrite(9, LOW);
delayMicroseconds(20000-d*10);
}
the servo goes to 90 deg
can someone please help me ?