Simple “Pass Through” Code
int ThroPin = A0;
int AilePin = A1;
int ElevPin = A2;
int RuddPin = A3;
int GearPin = A4;
int ThroOut = 5;
int AileOut = 6;
int ElevOut = 7;
int RuddOut = 8;
int GearOut = 9;
int pwm_value;
byte PWM_PIN = 3;
void setup() {
//pinMode(ThroPin, INPUT);
//pinMode(AilePin, INPUT);
//pinMode(ElevPin, INPUT);
//pinMode(RuddPin, INPUT);
//pinMode(GearPin, INPUT);
pinMode(PWM_PIN, INPUT);
//pinMode(ThroOut, OUTPUT);
//pinMode(AileOut, OUTPUT);
//pinMode(ElevOut, OUTPUT);
//pinMode(RuddOut, OUTPUT);
//pinMode(GearOut, OUTPUT);
Serial.begin(9600);
}
void loop() {
pwm_value = pulseIn(PWM_PIN, HIGH);
Serial.println(pwm_value);
int ThroPin = analogRead(A0);
int AilePin = analogRead(A1);
int ElevPin = analogRead(A2);
int RuddPin = analogRead(A3);
int GearPin = analogRead(A4);
//float voltageThro = ThroPin*(5.0/1023.0);
//float voltageAile = ThroPin*(5.0/1023.0);
//float voltageElev = ThroPin*(5.0/1023.0);
//float voltageRudd = ThroPin*(5.0/1023.0);
//float voltageGear = ThroPin*(5.0/1023.0);
analogWrite(ThroOut,voltageThro);
analogWrite(AileOut,voltageAile);
analogWrite(ElevOut,voltageElev);
analogWrite(RuddOut,voltageRudd);
analogWrite(GearOut,voltageGear);
//analogWrite(12.8); // PWM output for throttle duty cycle 5.1
}
Recent Comments