Free Source Code /* Board No 1 for right motor IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected Board No 2 for left motor IBT-2 pin 1 (RPWM) to Arduino pin 8(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 9(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected */ int RPWM1_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM) MOTOR1 int LPWM1_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM) MOTOR1 int RPWM2_Output = 8; // Arduino PWM output pin 8; connect to IBT-2 pin 1 (RPWM) MOTOR2 int LPWM2_Output = 9; // Arduino PWM output pin 9; connect to IBT-2 pin 2 (LPWM) MOTOR2 int motorSpeedA = 0; void setup() { pinMode(A0,INPUT) ; // connected to CH2 forward and reverse pinMode(A1,INPUT); // connected to CH1 turn Left and right Serial.begin(9600); pinMode(RPWM1_Output, OUTPUT); // Rigth side pinMode(LPWM1_Output, OUTPUT); pinMode(RPWM2_Output, OUTPUT); // Left side pinMode(LPWM2_Output, OUTPUT); } void loop() { int rcValue1 = pulseIn(A0 , HIGH); int rcValue2 = pulseIn(A1 , HIGH); if (rcValue1 >= 1500 and rcValue1 < 1900) // Reverse { motorSpeedA = map(rcValue1 , 1500, 1900, 1 , 255); analogWrite(RPWM1_Output, motorSpeedA); // มอเตอร์ บวก ต่อ กับ BTS ขั้วบวก analogWrite(LPWM1_Output, 0); analogWrite(RPWM2_Output, 0); // มอเตอร์ บวก ต่อ กับ BTS ขั้วบวก analogWrite(LPWM2_Output, motorSpeedA); } else if (rcValue1 >=1000 and rcValue1 = 1000 and rcValue2 = 1500 and rcValue2
@wizmachinery15205 жыл бұрын
ขอบคุณที่แบ่งปันกันโค๊ดนะครับ
@loksamanya88085 жыл бұрын
Wiz Machinery ยินดีครับ
@ionitacristian14072 жыл бұрын
A small error in the electrical circuit and the program code. Arduino pin 8 is not a PWM pin. Pin 10 (PWM) can be used, with the corresponding modification of the wiring diagram and the program code: /* Board No 1 for right motor IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected Board No 2 for left motor IBT-2 pin 1 (RPWM) to Arduino pin 9(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 10(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected */ int RPWM1_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM) MOTOR1 int LPWM1_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM) MOTOR1 int RPWM2_Output = 9; // Arduino PWM output pin 9; connect to IBT-2 pin 1 (RPWM) MOTOR2 int LPWM2_Output = 10; // Arduino PWM output pin 10; connect to IBT-2 pin 2 (LPWM) MOTOR2 int motorSpeedA = 0; void setup() { pinMode(A0,INPUT) ; // connected to CH2 Forward and Reverse pinMode(A1,INPUT); // connected to CH1 turn Left and Right Serial.begin(9600); pinMode(RPWM1_Output, OUTPUT); // Rigth side pinMode(LPWM1_Output, OUTPUT); pinMode(RPWM2_Output, OUTPUT); // Left side pinMode(LPWM2_Output, OUTPUT); } void loop() { { int rcValue1 = pulseIn(A0 , HIGH); int rcValue2 = pulseIn(A1 , HIGH); if (rcValue1 >= 1500 and rcValue1 < 1900) // Reverse { motorSpeedA = map(rcValue1 , 1500, 1900, 1 , 255); analogWrite(RPWM1_Output, motorSpeedA); // analogWrite(LPWM1_Output, 0); analogWrite(RPWM2_Output, 0); // analogWrite(LPWM2_Output, motorSpeedA); } else if (rcValue1 >=1000 and rcValue1 = 1000 and rcValue2 = 1500 and rcValue2
1.connect receiver to battery (5v) 2.press and hold Bind button 3.Switch on Remote control
@pierangelomariano80943 жыл бұрын
dear friend, i wish to make a similar project and i bought all the necessary. On the electronic side, I repeated all the connections between arduino, bts7960, flysky i6x and fsai6b receiver and charged your sketch: all seems correct, but when i try the system (with one battery 12 v 12 ah full charged ) only one motor goes automatically (only in one direction) and flysky throttle doesn't drive nothing (the receiver is correctly bound). I don't think that the reason is only the battery (in my project i had to connect two other batteries because the motors are 350w 36 v) I am not expert of electronics and Arduino and simply have replied your scheme. What is wrong?
@ionitacristian14072 жыл бұрын
A small error in the electrical circuit and the program code. Arduino pin 8 is not a PWM pin. Pin 10 (PWM) can be used, with the corresponding modification of the wiring diagram and the program code: /* Board No 1 for right motor IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected Board No 2 for left motor IBT-2 pin 1 (RPWM) to Arduino pin 9(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 10(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected */ int RPWM1_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM) MOTOR1 int LPWM1_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM) MOTOR1 int RPWM2_Output = 9; // Arduino PWM output pin 9; connect to IBT-2 pin 1 (RPWM) MOTOR2 int LPWM2_Output = 10; // Arduino PWM output pin 10; connect to IBT-2 pin 2 (LPWM) MOTOR2 int motorSpeedA = 0; void setup() { pinMode(A0,INPUT) ; // connected to CH2 Forward and Reverse pinMode(A1,INPUT); // connected to CH1 turn Left and Right Serial.begin(9600); pinMode(RPWM1_Output, OUTPUT); // Rigth side pinMode(LPWM1_Output, OUTPUT); pinMode(RPWM2_Output, OUTPUT); // Left side pinMode(LPWM2_Output, OUTPUT); } void loop() { { int rcValue1 = pulseIn(A0 , HIGH); int rcValue2 = pulseIn(A1 , HIGH); if (rcValue1 >= 1500 and rcValue1 < 1900) // Reverse { motorSpeedA = map(rcValue1 , 1500, 1900, 1 , 255); analogWrite(RPWM1_Output, motorSpeedA); // analogWrite(LPWM1_Output, 0); analogWrite(RPWM2_Output, 0); // analogWrite(LPWM2_Output, motorSpeedA); } else if (rcValue1 >=1000 and rcValue1 = 1000 and rcValue2 = 1500 and rcValue2
hello, I wanted to congratulate you on the project, I'm also trying to do it, but I can't go forward or backward .. my robot only turns right and left .. I also have the FLYSKY can you help me?
@loksamanya88084 жыл бұрын
Thank you for your interest in my project. Have you used the bts7960 motor drive board and arduino board like my project? I have shown the code at the first comment. You can upload code to arduino board immediately without any modification, you can control both motors to go forward or backward and turn left and right with flysky remote control. Have fun !!
@alessandro_sgarbi4 жыл бұрын
@@loksamanya8808 Hi, no I have the 2x12 Rc sabertooth with the FLYSKY remote..but I don't understand why I can't go back and forth.
@loksamanya88084 жыл бұрын
@@alessandro_sgarbi Sorry! .I have no experience with sabortooth before but I 've ever seen the tutorial clip how to set up sabortooth with analog signal at kzbin.info/www/bejne/nIOWe3l9iqeNq7c . May be helpful for you .
@alessandro_sgarbi4 жыл бұрын
@@loksamanya8808 thanks a lot anyway, I try to watch the video you linked to me. bye Bye
@gabelim743 жыл бұрын
@@alessandro_sgarbi you need to check cable connection. I had the same issue and later found out that the cables were connected wrong. read the sabertooth instruction and you'll figure it out.
@DIY-pm8ko3 жыл бұрын
ผมลองแล้วใช้ได้ครับ ดีใจมากครับที่ท่าน Lok Samanya กรุณาแจกโค้ดให้ ต้องขอบคุณอย่างสูง (ผมเขียนเองไม่ได้55) แต่ผมลองโหลดใส่บอร์ด อูโน่ ของผม สัญอนาลอกที่ออกช่องเอ้าพุท8 มันไม่ออกเป็นPWM ผมเลยย้ายจากช่อง8ไปเป็นช่อง10 แล้วสามารถใช้ได้ตามโค้ดข้างล่างครับ /* Board No 1 for right motor IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected Board No 2 for left motor IBT-2 pin 1 (RPWM) to Arduino pin 8(PWM) IBT-2 pin 2 (LPWM) to Arduino pin 9(PWM) IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin IBT-2 pin 8 (GND) to Arduino GND IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected */ int RPWM1_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM) MOTOR1 int LPWM1_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM) MOTOR1 int RPWM2_Output = 10; // Arduino PWM output pin 10; connect to IBT-2 pin 1 (RPWM) MOTOR2 int LPWM2_Output = 9; // Arduino PWM output pin 9; connect to IBT-2 pin 2 (LPWM) MOTOR2 int motorSpeedA = 0; void setup() { pinMode(A0,INPUT) ; // connected to CH2 forward and reverse pinMode(A1,INPUT); // connected to CH1 turn Left and right Serial.begin(9600); pinMode(RPWM1_Output, OUTPUT); // Rigth side pinMode(LPWM1_Output, OUTPUT); pinMode(RPWM2_Output, OUTPUT); // Left side pinMode(LPWM2_Output, OUTPUT); } void loop() { int rcValue1 = pulseIn(A0 , HIGH); int rcValue2 = pulseIn(A1 , HIGH); if (rcValue1 >= 1500 and rcValue1 < 2100) // Reverse { motorSpeedA = map(rcValue1 , 1500, 2100,0 , 255); analogWrite(RPWM1_Output, motorSpeedA); // มอเตอร์ บวก ต่อ กับ BTS ขั้วบวก analogWrite(LPWM1_Output, 0); analogWrite(RPWM2_Output, 0); // มอเตอร์ บวก ต่อ กับ BTS ขั้วบวก analogWrite(LPWM2_Output, motorSpeedA); } else if (rcValue1 >=900 and rcValue1 = 900 and rcValue2 = 1500 and rcValue2
@loksamanya88083 жыл бұрын
เยี่ยมเลยครับ ผมก็หัดเขียนโค้ดแรกบน arduino ก็ตัวนี้แหละครับ งมโข่งอยู่หลายวันเหมือนกัน กว่าจะปรับจูนให้เข้ากับ remote control ได้