Forum Replies Created
- AuthorPosts
- lacoste2500Participant
no body can help ??????????????????
June 28, 2016 at 12:21 pm in reply to: Arduino + NRF24L01 Radio Module RC Control Tutorial Code #1733lacoste2500Participantwant add an servo motor ,is possible ?
lacoste2500Participantthis the code
/*
Crane Reciever Code
*/// Variables used in the program
int Motor_1_Speed = 127;
int Motor_2_Speed = 127;
int Motor_3_Speed = 127;
int Magnet_State = 1;
int LED_State = 0;
int move1 = 0;
int LED2_State = 0;
int LED3_State = 0;
int LED4_State = 0;uint8_t buf[8];
#include <SPI.h>
#include “RF24.h”RF24 radio(9,10);
// Controller Address
const uint64_t Controller_1 = 0xE8E8F0F0E1LL;void setup()
{pinMode(2, OUTPUT); // Motor 1 Direction 1
pinMode(3, OUTPUT); // Motor 1 PWM
pinMode(4, OUTPUT); // Motor 1 Direction 2
pinMode(5, OUTPUT); // Motor 2 PWM
pinMode(5, OUTPUT); // Motor 3 PWM
pinMode(7, OUTPUT); // Motor 2 Direction 1
pinMode(8, OUTPUT); // Motor 2 Direction 2
pinMode(A0, OUTPUT); // Motor 3 Direction 1
pinMode(A1, OUTPUT); // Motor 3 Direction 2
pinMode(A2, OUTPUT); // Magnet Pin
pinMode(A3, OUTPUT); // LED Pin
pinMode(A4, OUTPUT); // LED Pin
pinMode(A5, OUTPUT); // LED Pin
pinMode(A6, OUTPUT); // LED Pin
pinMode(A7, OUTPUT); // LED Pinradio.begin(); // Initialize the NRF24 Radio Module
radio.openReadingPipe(1,Controller_1); // Set Address of Controller 1
radio.startListening(); // Start listening for commands from the controllers
}void loop()
{
if (radio.available())radio.read(buf, 8);{
Motor_1_Speed = buf[0];
Motor_2_Speed = buf[1];
Motor_3_Speed = buf[2];
Magnet_State = buf[3];
LED_State = buf[4];
LED2_State = buf[5];
LED3_State = buf[6];
LED4_State = buf[7];update_motor(Motor_1_Speed,3,2,4);
update_motor(Motor_2_Speed,5,7,8);
update_motor(Motor_3_Speed,6,A0,A1);//Turn on LIHGT AVANT
if(Magnet_State==1){
digitalWrite(A2,HIGH);
}
else{
digitalWrite(A2,LOW);
}
//Turn on or OFF LED 2
if(LED2_State==1){
digitalWrite(A6,HIGH);
}
else{
digitalWrite(A6,LOW);
}
//Turn on or off the magnet
if(LED3_State==1){
digitalWrite(A7,HIGH);
}
else{
digitalWrite(A7,LOW);
}
//Turn LEFT
if(LED4_State==1){
digitalWrite(A5,HIGH);
delay(500);
digitalWrite(A5,LOW);
delay(500);
}
//Turn RIHGT
if(LED3_State==1){
digitalWrite(A4,HIGH);
delay(500);
digitalWrite(A4,LOW);
delay(500);
}
//Turn on REAR LIHGT
if(LED_State==1){
digitalWrite(A3,HIGH);
}
else{
digitalWrite(A3,LOW);
}}
}void update_motor(int drive_val, int motor_pwm, int motor_dir1, int motor_dir2){
if (drive_val < 120){ // These if functions leave a buffer zone of 15 bits above and below the drive center value
move1 = map(drive_val, 120, 0, 0,255);//drive_min, drive_max); // scale the data value for use with the motor
analogWrite(motor_pwm,move1); // Set the PWM vlue on pin 5 to move the motor
digitalWrite(motor_dir1, HIGH); // Set the direction with pins 7 and 8
digitalWrite(motor_dir2, LOW);
}
else if (drive_val > 135){
move1 = map(drive_val, 135, 255, 0,255);//drive_min, drive_max); // scale the data value for use with the motor
analogWrite(motor_pwm,move1); // Set the PWM vlue on pin 5 to move the motor
digitalWrite(motor_dir2, HIGH); // Set the direction with pins 7 and 8
digitalWrite(motor_dir1, LOW);}
else{
move1=0;
analogWrite(motor_pwm,move1); // Set the PWM vlue on pin 5 to move the motor
digitalWrite(motor_dir1, LOW); // Set the direction with pins 7 and 8
digitalWrite(motor_dir2, LOW);
}}
lacoste2500ParticipantHi here is the full zip just download zip and unzipped it on library
https://github.com/JohnDRoach/Mx5DataLoggerlacoste2500ParticipantHello i’m tryin to build an RC car wthit nrf24 and 2 joystik first one for forward/backward with variable speed pwm and second one for direction .note the car not have a servo motor just 2 CC motor for direction and back/forward ,and i put 2 leds for front lihgt controled by button A and 2 leds for stop and 2 leds for turn left and rihgt controled by 2 button B/C left/rihgt and if possible to turn light left and rihgt on the same time , so please can You modify the code for me ,i do it but it have some mistakes ,wen i turn on the lihgt for turning rihgt or left is blinking but wen i try to run it take delay of time to responding the same thing for all the function ,please help
lacoste2500ParticipantHello i’m trayin to build an RC car wthit nrf24 and 2 joystik first one for forward/backward with variable speed pwm and second one for direction .note the car not have a servo motor just 2 CC motor for direction and back/forward ,and i put 2 leds for front lihgt controled by button and 2 leds for stop and 2 leds for turn left and rihgt controled by 2 button left/rihgt and if possible to turn light left and rihgt on same time , so please can You modify the code
lacoste2500Participantyesssssssssss love you men
is working , i’m gonna upload the code in arduino to night and try them ,thank you ,i’m a big fun for yours videos and your project ,thank youu a lotlacoste2500Participanthi thank you for ansewer me ,i get this error ,yes i get the new library and i unzipped in library in arduino but still have this error only in the second part of the code ,the first one is ok no error ,
Arduino : 1.6.7 (Windows XP), Carte : “Arduino Nano, ATmega328”
C:\DOCUME~1\admin\LOCALS~1\Temp\arduino_79f2126b6194cdc12557d337d7596677\sketch_mar23a.ino:88:96: fatal error: SendOnlySoftwareSerial.h: No such file or directory
#include <SendOnlySoftwareSerial.h> // Include the library for creating additional serial ports
^
compilation terminated.
exit status 1
Erreur lors de la compilation.lacoste2500Participanthi i have a problem withe scend part of the code ;arduino ide tell me compilation terminated exit status 1 please help me please it have been long time searching for code like yours great job
- AuthorPosts