Arduino based project , RC signal to 0-5V converter, Arduino UNO and LTC264412E 12BIT PWM to DAC board is used, Arduino converter RC signal to 0 to 100% Duty Cycle PWM, DAC converters PWM signal in to Voltage.
DAC Module Schematic and PCB Layout
Arduino Pins
RC Signal Input = Arduino UNO D5
PWM Output = Arduino Uno D10
.........................................................................
Arduino Code
.........................................................................
int joystickX= 10;
int rc_channel1 = 5;
void setup() {
pinMode(rc_channel1, INPUT);
pinMode(joystickX, OUTPUT);
Serial.begin(9600);
}
void loop() {
int pwm = 127;
int rc1 = pulseIn(rc_channel1, HIGH, 25000);
Serial.print(" raw channel1: ");
Serial.print(rc1);
if(rc1==0){
Serial.println(" no signal");
analogWrite(joystickX, 127);
}
else if(rc1 > 1530){ //right stick
pwm = map(rc1, 1530, 2000, 128, 255); //map our speed to 127-255 range
analogWrite(joystickX, pwm);
Serial.print(" right stick speed: ");
Serial.println(pwm);
}
else if(rc1 < 1460){ //left stick
pwm = map(rc1, 993, 1460, 1, 126); //map our speed to 1-126 range
analogWrite(joystickX, pwm);
Serial.print(" left stick speed: ");
Serial.println(pwm);
}else{
Serial.println(" stick centered");
analogWrite(joystickX, 127);
}
delay(10);
}
Comments