Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //************************************************
- // Control Motor From 4 Channel RC Remote Control
- // First Step 2 Channel Only
- //************************************************
- #include <ATX2.h>
- int A,X,Y,Z=0,CH1,CH2,CH3,CH4;
- void setup(){
- pinMode(26,INPUT);
- pinMode(27,INPUT);
- pinMode(28,INPUT);
- pinMode(29,INPUT);
- }
- void loop(){
- CH1 = pulseIn(27, HIGH, 25000);
- CH2 = pulseIn(26, HIGH, 25000);
- if(CH2>1600){
- if(CH1<1400){
- A=map(CH1,1000,1400,100,0);
- motor(12,A);motor(34,-A);
- }
- else if (CH1>1600){
- A=map(CH1,1600,1990,0,100);
- motor(12,-A);motor(34,A);
- }
- else {
- A=map(CH2,1600,1990,0,100);
- motor(12,A);motor(34,A);
- }
- }
- else if(CH2<1400){
- if(CH1<1400){
- A=map(CH1,1000,1400,100,0);
- motor(12,-A);motor(34,A);
- }
- else if (CH1>1600){
- A=map(CH1,1600,1990,0,100);
- motor(12,A);motor(34,-A);
- }
- else {
- A=map(CH2,1000,1400,100,0);
- motor(12,-A);motor(34,-A);
- }
- }
- else{
- if(CH1<1400){
- A=map(CH1,1000,1400,100,0);
- motor(12,A);motor(34,-A);
- }
- else if (CH1>1600){
- A=map(CH1,1600,1990,0,100);
- motor(12,-A);motor(34,A);
- }
- else {
- motor(12,0);motor(34,0);
- }
- }
- CH3 = pulseIn(28, HIGH, 25000);
- CH4 = pulseIn(29, HIGH, 25000);
- }
- void FD1 (int speed1,int speed2){
- motor(12,speed1);
- motor(34,speed1);
- }
Advertisement
Add Comment
Please, Sign In to add comment