Hey:
I bought my first robot callled three-wheeled smart cart kit. With the program i have this to put in my programing
#include <SPI.h>
#include "RF24.h"
RF24 radio(9, 10); // define the object to control NRF24L01
const byte addresses[6] = "Free1";// define communication address which should correspond to remote control
// servo
#include <Servo.h>
Servo dirServo; // define servo to control turning of smart car
const int dirServoPin = 2; // define pin for signal line of the last servo
byte dirServoOffset = 0; // define a variable for deviation(degree) of the servo
// motor
const int dirAPin = 7, // define pin used to control rotational direction of motor A
pwmAPin = 6, // define pin for PWM used to control rotational speed of motor A
dirBPin = 4, // define pin used to control rotational direction of motor B
pwmBPin = 5, // define pin for PWM used to control rotational speed of motor B
snsAPin = A0, // define pin for detecting current of motor A
snsBPin = A1, // define pin for detecting current of motor B
buzzerPin = 3, // define pin for buzzer
ledRPin = A3, // define R pin of RGBLED
ledGPin = A4, // define G pin of RGBLED
ledBPin = A5; // define B pin of RGBLED
const byte motorSpeed = 255; // define motor speed(0-255)
#define FORWARD LOW
#define BACKWARD HIGH
// wireless communication
int dataRead[8]; // define array used to save the read data
const unsigned long wirelessOvertime = 200; // define communication overtime(ms)
unsigned long lastReceivedSignal; // define a variable to save the time(ms) of last received the signal
void setup() {
// serial port
Serial.begin(115200);
// NRF24L01
radio.begin(); // initialize RF24
radio.setPALevel(RF24_PA_LOW); // set power amplifier (PA) level
radio.setDataRate(RF24_1MBPS); // set data rate through the air
radio.setRetries(0, 15); // set the number and delay of retries
radio.openWritingPipe(addresses); // open a pipe for writing
radio.openReadingPipe(1, addresses);// open a pipe for reading
radio.startListening(); // start monitoringtart listening on the pipes opened
// servo
dirServo.attach(dirServoPin); // attaches the servo on dirServoPin to the servo object
// motor
pinMode(dirAPin, OUTPUT); // set dirAPin to output mode
pinMode(pwmAPin, OUTPUT); // set pwmAPin to output mode
pinMode(dirBPin, OUTPUT); // set dirBPin to output mode
pinMode(pwmBPin, OUTPUT); // set pwmBPin to output mode
// pin
pinMode(buzzerPin, OUTPUT); // set buzzerPin to output mode
pinMode(ledRPin, OUTPUT); // set ledRPin to output mode
pinMode(ledGPin, OUTPUT); // set ledGPin to output mode
pinMode(ledBPin, OUTPUT); // set ledBPin to output mode
digitalWrite(ledRPin, HIGH); // turn off R LED
digitalWrite(ledGPin, HIGH); // turn off G LED
digitalWrite(ledBPin, HIGH); // turn off B LED
}
void loop()
{
// read radio data
if ( radio.available()) { // if receive the data
while (radio.available()) { // read all the data
radio.read(dataRead, sizeof(dataRead)); // read data
}
// calculate the angle of turning
int dirServoDegree = map(dataRead[2], 0, 1023, 135, 45) - (dataRead[0] - 512) / 25;
// calculate speed of moving
int motorSpd = dataRead[3] - 512 + (dataRead[1] - 512) / 10;
bool motorDir = motorSpd > 0 ? BACKWARD : FORWARD;
motorSpd = abs(constrain(motorSpd, -512, 512));
motorSpd = map(motorSpd, 0, 512, 0, motorSpeed);
// control the turning and moving of the car
ctrlCar(dirServoDegree, motorDir, motorSpd);
// control the buzzer
if (!dataRead[4])
tone(buzzerPin, 2000);
else
noTone(buzzerPin);
// control the RGB LED
digitalWrite(ledRPin, dataRead[5]);
digitalWrite(ledGPin, dataRead[6]);
digitalWrite(ledBPin, dataRead[7]);
// save the time of last received the wireless signal
lastReceivedSignal = millis();
}
else {
// if lose wireless signal for a long time
if (millis() - lastReceivedSignal >= wirelessOvertime) {
// stop the car
analogWrite(pwmAPin, 0);
analogWrite(pwmBPin, 0);
// turn off the buzzer
noTone(buzzerPin);
// turn off the RGB LED
digitalWrite(ledRPin, HIGH);
digitalWrite(ledGPin, HIGH);
digitalWrite(ledBPin, HIGH);
}
}
// send motor current to serial port Serial.print(iMotorB);
Serial.println(" A");
im noob so i thing that if a put this in my robot i can move it but when i going to put it said this error:
Arduino:1.8.4 (Windows 7), Tarjeta:"Arduino/Genuino Uno"
C:\Users\Jhonandretti\Desktop\arduino\Freenove_Three-wheeled_Smart_Car_Kit_for_Arduino-master\Sketches\Remote_control\Remote_control_Car\Remote_control_Car.ino:2:18: fatal error: RF24.h: No such file or directory
#include "RF24.h"
^
compilation terminated.
exit status 1
Error compilando para la tarjeta Arduino/Genuino Uno.
Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
please help