Hi
Please can someone help?
I want to send servo positions from one pro mini (the controller) to another (the actuator) but am having compile error. I suspect the libraries are incompatible or use the same variables or timer.
can anyone suggest a workaround?
Error details:
In file included from C:\Users\user\Google Drive\Arduino\libraries\RadioHead/RHGenericDriver.h:9:0,
from C:\Users\user\Google Drive\Arduino\libraries\RadioHead/RH_ASK.h:9,
from C:\Users\user\Google Drive\Arduino\askradioheadtrial\askradioheadtrial.ino:2:
C:\Users\user\Google Drive\Arduino\libraries\RadioHead/RadioHead.h:305:51: warning: "/*" within comment [-Wcomment]
cp /usr/local/projects/arduino/libraries/RadioHead/*.h .
C:\Users\user\Google Drive\Arduino\libraries\RadioHead/RadioHead.h:306:51: warning: "/*" within comment [-Wcomment]
cp /usr/local/projects/arduino/libraries/RadioHead/*.cpp .
C:\Users\user\Google Drive\Arduino\askradioheadtrial\askradioheadtrial.ino: In function 'void loop()':
C:\Users\user\Google Drive\Arduino\askradioheadtrial\askradioheadtrial.ino:25:9: warning: unused variable 'i' [-Wunused-variable]
int i;
^
libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':
(.text+0x0): multiple definition of `__vector_11'
libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Pro or Pro Mini.
the code is:
//receiver
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <Servo.h>
Servo myservo; // create servo object to control a servo
RH_ASK driver(2000, 11, 12, 0); // speed 2000, rx-pin 11 , tx-pin 12
void setup()
{
Serial.begin(9600); // Debugging only
myservo.attach(9);
if (!driver.init()) { //for receiver driver
Serial.println("init failed");
} else {
Serial.println("RX Ready");
}
}
void loop() {
myservo.write(111); // just to ensure servo is complied
uint8_t buf[10];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) {// Non-blocking
int i;
// Message with a good checksum received, dump it.
//Serial.println("");
Serial.print("Message: ");
//Serial.println(buf);
Serial.println((char*)buf);
digitalWrite(13, 1);//flash led if received
delay(10);
digitalWrite(13, 0);
}
}
I'm trying to remote control 3 servos by continually sending packets of 3 servo angles 0-180.
I'm also having issues with replacing "hello" with a numeric variable (int or uint8_t) in the Radiohead ask example below.
const char *msg = "hello";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
For completeness the full example code is below. I have swapped line RH_ASK driver; for RH_ASK driver(2000, 4, 5, 0) where 2000 is TX rate, 4 is TXpin, 5 is RXpin 0 is PTT pin (unused) :
// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module
// Tested on Arduino Mega, Duemilanova, Uno, Due, Teensy, ESP-12
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 4, 5, 0); // ESP8266 or ESP32: do not use pin 11 or 2
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
const char *msg = "hello";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(200);
}
and the RX arduino example code is
// ask_receiver.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to receive messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) receiver with an Rx-B1 module
// Tested on Arduino Mega, Duemilanova, Uno, Due, Teensy, ESP-12
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
// RH_ASK driver(2000, 4, 5, 0); // ESP8266 or ESP32: do not use pin 11 or 2
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
driver.printBuffer("Got:", buf, buflen);
}
}