Witam !
mam problem z dodaniem biblioteki <Servo.h> do mojego projektu poniżej szkic
[ proszę poprawić kod zgodnie z instrukcją: topic7402.html bo inaczej wątek zostanie usunięty - mirekk36 ]błąd :
libraries\Servo\avr\Servo.cpp.o: In function `__vector_11':
C:\Program Files (x86)\Arduino\libraries\Servo\src\avr/Servo.cpp:81: multiple definition of `__vector_11'
libraries\RadioHead\RH_ASK.cpp.o:C:\Users\Anetka\Documents\Arduino\libraries\RadioHead/RH_ASK.cpp:514: first defined here
collect2.exe: error: ld returned 1 exit status
szkic :
D0
D1
D2
D3 PWMA Silnik
D4 LED Pin
D5 PWMA Silnik
D6 AIN1
D7 AIN2
D8 NRF24 CE
D9
D10 NRF24 CSN
D11 NRF24 MOSI
D12 NRF24 MISO
D13 NRF24 SCK
A0
A1
A2
A3
A4
A5
*/
// This section describes the vehicle (this ID is JD83)
byte ID1 = 0x4A; // Enter a four byte ID for the vehicle
byte ID2 = 0x44; // for example F936 for the Fendt 936 model
byte ID3 = 0x38; // would be ID1 = 0x46; ID2 = 0x39; ID3 = 0x33; ID4 = 0x36
byte ID4 = 0x33; // because asci character F is 46 in hexidecimal and so on
// Variables used in the program
int Move_1 = 125;
int Move_2 = 125;
int Move_3 = 125;// Variable used to determine the motor direction
byte Command_Val = 0x00; // Stores the command value
byte Data_Val_1 = 0x00; // Stores the data value
byte Data_Val_2 = 0x00; // Stores the data value
byte Data_Val_3 = 0x00; // Stores the data value
byte Data_Val_4 = 0x00; // Stores the data value
byte Data_Val_5 = 0x00; // Stores the data value
byte Data_Val_6 = 0x00; // Stores the data value
// Include Libraries
#include <SPI.h>
#include <RH_NRF24.h>
RH_NRF24 nrf24; // Create NRF24 object
void setup()
{
pinMode(4, OUTPUT); // Set digital pin 4 as an output
nrf24.init(); // Initiailize NRF24 radio module
nrf24.setChannel(1); // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm);
}
void loop()
{
if (nrf24.available()) // If the NRF24 has recieved data
{
uint8_t buf[11]; // Create array to store it in
uint8_t len = sizeof(buf);
if (nrf24.recv(buf, &len)) // Store the data
{
// We recieved a string of ten bytes, four ID, one command and six data values but they may not be for this tractor
if (buf[0] == ID1 && buf[1] == ID2 && buf[2] == ID3 && buf[3] == ID4){ // Confirm that the correct vehicle ID has been recieved
Command_Val = buf[4]; // Store the new command value
Data_Val_1 = buf[5]; // Store the new data value
Data_Val_2 = buf[6]; // Store the new data value
Data_Val_3 = buf[7]; // Store the new data value
Data_Val_4 = buf[8]; // Store the new data value
Data_Val_5 = buf[9]; // Store the new data value
Data_Val_6 = buf[10]; // Store the new data value
}
}
// Servo not simple, NRF24 and servo libraries trying to use the same timer
// Motor Control
// Data recieved is between 0 and 255. The center is 255/2=127.5 and we want a buffer zone around here to stop the tractor from moving unexpectedly.
if (Data_Val_5 < 120){ // This if function create a buffer zone of 7.5 bits below 127.5
Move_1 = map(Data_Val_5, 120, 0, 0,255); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(5,Move_1); // Set the PWM value on pin 5 to move the motor
}
else if (Data_Val_5 > 135){ // This if function create a buffer zone of 7.5 bits above 127.5
Move_1 = map(Data_Val_5, 5, 0, 0,0); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(5,Move_1); // Set the PWM vlue on pin 5 to move the motor
}
else{ // Every other value is in the buffer zone
Move_1=0;
analogWrite(5,Move_1); // Set the PWM to 0%
// Set the direction with pins 6 and 7 but not necessary
}
/////////////////////////////////////////////
// Motor Control
// Data recieved is between 0 and 255. The center is 255/2=127.5 and we want a buffer zone around here to stop the tractor from moving unexpectedly.
if (Data_Val_5 < 120){ // This if function create a buffer zone of 7.5 bits below 127.5
Move_2 = map(Data_Val_5, 5, 0, 0,0); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(3,Move_2); // Set the PWM value on pin 5 to move the motor
}
else if (Data_Val_5 > 135){ // This if function create a buffer zone of 7.5 bits above 127.5
Move_2 = map(Data_Val_5, 120, 255, 0,255); // PWM is 0% at 0 and 100% at 255 so scale the data value for use with the motor
analogWrite(3,Move_2); // Set the PWM vlue on pin 5 to move the motor
}
else{ // Every other value is in the buffer zone
Move_2=0;
analogWrite(3,Move_2); // Set the PWM to 0%
}
////////////////////////SERVO//////////////////////////////
// LED Control
if(Data_Val_6==1){
digitalWrite(4, HIGH); // Turn LED on
}
else {
digitalWrite(4, LOW); // Turn LED off
}
}
}