Complete newbie here so please be nice
i am trying to control 2 x l298n motor drivers from my flysky rc receiver ,
i am wanting to have 4 separate channels controlling 4 separate motors , no mixing or anything , dont need to have any speed control , just need the motors to go forward and reverse at max stick travel and off in center
i have searched everywhere and cant find a code for this application so i attempted to take bits from a code and rewrite to get what i need ,
This is the rubbish code i came up with its probably completely wrong so please can anyone help me , i need it for a big project im working on
double ch1=1;
int a=5; int b=6;
double ch2=2;
int c=7; int d=8;
double ch3=3;
int e=9; int f=10;
double ch4=4;
int g=11; int h=12;
void setup()
{
Serial.begin(9600);
pinMode(1,INPUT);
pinMode(5,OUTPUT); pinMode(6,OUTPUT);
pinMode(2,INPUT);
pinMode(7,OUTPUT); pinMode(8,OUTPUT);
pinMode(3,INPUT);
pinMode(9,OUTPUT); pinMode(10,OUTPUT);
pinMode(4,INPUT);
pinMode(11,OUTPUT); pinMode(12,OUTPUT);
}
void loop()
{
ch1 = pulseIn(1,HIGH);
ch2 = pulseIn(2,HIGH);
ch3 = pulseIn(3,HIGH);
ch4 = pulseIn(4,HIGH);
{
(ch1==0)
digitalWrite(a,LOW); digitalWrite(b,HIGH);
(ch1>1530)
digitalWrite(a,HIGH); digitalWrite(b,LOW);
}
{
(ch2==0)
digitalWrite(c,LOW); digitalWrite(d,HIGH);
(ch2>1530)
digitalWrite(c,HIGH); digitalWrite(d,LOW);
}
{
(ch3==0)
digitalWrite(e,LOW); digitalWrite(f,HIGH);
(ch3>1530)
digitalWrite(e,HIGH); digitalWrite(f,LOW);
}
{
(ch4==0)
digitalWrite(g,LOW); digitalWrite(h,HIGH);
(ch4>1530)
digitalWrite(g,HIGH); digitalWrite(h,LOW);
}
