#include "Arduino.h"
//Test with Channel 1
//Test with switch SWB
//we declare the inputs to them we connect our RC from 1 channel and SWB
int ch1=3;
int ch6=5;
//we declare outputs we connect LEDs to them
int sd1 = 7;
int sd6 = 8;
//variables for recording the signal
int sig1;
int sig6;
//variables for PWM control
int forward;
int plow;
void setup()
{
//assign pins as inputs
pinMode(ch1, INPUT);
pinMode(ch6, INPUT);
//assign pins as outputs
pinMode(sd1,OUTPUT);// Cha1 Left :1005 Right 1981
pinMode(sd6,OUTPUT);// OFF 1981 ON 994
//just in case, set the speed to the Serial port so that you can see what is happening in the program
Serial.begin(9600);
}
void loop()
{
//we record the readings of the receiver
sig1 = pulseIn(ch1, HIGH);
sig6 = pulseIn(ch6, HIGH);
if(sig1>1900)
{
digitalWrite(forward,HIGH);
}
//if(sig1<1000)
//{
// digitalWrite(forward,LOW);
//}
// These are the code for the if statement for the plow.
if(sig6>1900)
{
digitalWrite(plow,HIGH);
}
// if(sig6<1000)
//{
//digitalWrite(plow,LOW);
// }
//et the PWM ports to the value received from the receiver
digitalWrite(sd1,forward);
digitalWrite(sd6,plow);
//outputting data to the port monitor
//but it is not necessary, I used it when writing
//programs
Serial.println();
Serial.print("Input ch1");
Serial.print(": ");
Serial.print(sig1);
Serial.print(" ");
Serial.print("Input ch6");
Serial.print(": ");
Serial.print(sig6);
Serial.print(" ");
Serial.print("1");
Serial.print(": ");
Serial.print(forward);
Serial.print(" ");
Serial.print("2");
Serial.print(": ");
Serial.print(plow);
Serial.print(" ");
delay(200);
}