Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
- AuthorPosts
- October 21, 2015 at 4:59 am in reply to: hi please the code of ovladania As with JD 8360RT only from without serial commu #1358sisikarParticipant
yes but not work this link on your forum : Click here to view the RC John Deere 8360RT Code, my problem ist not work controler-cab-body , problem has my serial comunnication and that’s why replace only two motor. control – body
sisikarParticipantyes but only control arduino on arduino not serial communication.I build crawler and i like your steering RC John Deere 8360RT.
I have a functional model but need variables code for two motor control. code for Arduino in the control – code for Arduino in the bodyleft-right joystick X, forward-backward joystick Y
_________________________________________________________________
please modify receiver code/* NRF24L01 Module Demo Receiver Code Pin Assignment D0 D1 AIN3 D2 AIN4 D3 PWMB D4 LED Pin D5 PWMA D6 AIN1 D7 AIN2 D8 NRF24 CE D9 nova ledka 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; // Variable used to determine the motor direction int Move_2 = 125; 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 byte Data_Val_7 = 0x00; //nova ledka byte Data_Val_8 = 0x00; //Right_Joy_X byte Data_Val_9 = 0x00; //Right_Joy_Y float 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 pinMode(3, OUTPUT);// nova ledka Serial.begin(9600); 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[14]; // 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){ // ak sedia hodnoty tak je to pravda Command_Val = buf[4]; // Store the new command value Data_Val_1 = buf[5]; // variabilne priradene k setup 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]; // Left_Joy_X Data_Val_5 = buf[9]; // Left_Joy_Y Data_Val_6 = buf[10]; // Store the new data value Data_Val_7 = buf[11]; // nova ledka Data_Val_8 = buf[12]; //Right_Joy_X Data_Val_9 = buf[13]; //Right_Joy_Y } } // 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); Serial.print("analog read "); Serial.println(Data_Val_5);// Set the PWM value on pin 5 to move the motor digitalWrite(6, HIGH); // Set the direction with pins 6 and 7 digitalWrite(7, LOW); } else if (Data_Val_5 > 140){ // This if function create a buffer zone of 7.5 bits above 127.5 Move_1 = map(Data_Val_5, 140, 255, 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); Serial.print("analog read "); Serial.println(Data_Val_5);// Set the PWM vlue on pin 5 to move the motor digitalWrite(7, HIGH); // Set the direction with pins 6 and 7 digitalWrite(6, LOW); } else{ // Every other value is in the buffer zone Move_1=0; analogWrite(5,Move_1); // Set the PWM to 0% digitalWrite(6, LOW); // Set the direction with pins 6 and 7 but not necessary digitalWrite(7, LOW); } if (Data_Val_9 < 120){ // This if function create a buffer zone of 7.5 bits below 127.5 Move_2 = map(Data_Val_9, 120, 0, 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); Serial.print(" analog read "); Serial.println(Data_Val_9);// Set the PWM value on pin 5 to move the motor digitalWrite(4, HIGH); // Set the direction with pins 6 and 7 digitalWrite(2, LOW); } else if (Data_Val_9 > 140){ // This if function create a buffer zone of 7.5 bits above 127.5 Move_2 = map(Data_Val_9, 140, 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); digitalWrite(2, HIGH); // Set the direction with pins 6 and 7 digitalWrite(4, LOW); } else{ // Every other value is in the buffer zone Move_2=0; analogWrite(3,Move_2); // Set the PWM to 0% digitalWrite(4, LOW); // Set the direction with pins 6 and 7 but not necessary digitalWrite(2, LOW); } // LED Control if(Data_Val_6==1){ digitalWrite(1, HIGH); // Turn LED on } else { digitalWrite(1, LOW); // Turn LED off } // nova ledka if(Data_Val_7==1){ digitalWrite(9, HIGH); // Turn LED on } else { digitalWrite(9, LOW); // Turn LED off } } }
- AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)