GOAL: I am trying to integrate a relay switch on my quadcopter. I have the RC Crius Pro V1 board.
WHAT I'VE DONE: I want to read the PPM signal from channel 5 on my receiver by dedicating the A33 pin on the board to a digital input. I then added code to the main loop that will turn pin D8 high if the signal read into A33 is low (1080 micro seconds) and low if A33 is high (1800 micro seconds).
PROBLEM: Basically my problem is after I added the "pulseln" function into the code, it interrupts the serial tx when I use the MultiWii Conf ie. I can't get any sensor readings.
Do you think it would still be safe to fly? Or is there some danger in adding the "pulseln" function to the main loop.
Thanks!
Here's all the code I added to MultiWii.cpp, everything else is the same.
Code: Select all
// Declare global variable
int servoValue;
// This code inserted at the end of void setup()
pinMode(33,INPUT); //Receiver
pinMode(8,OUTPUT); //Relay
// This code inserted at the end of void loop()
servoValue = pulseIn(33, HIGH);
if ((servoValue > 500) && (servoValue < 1200))
{
digitalWrite(8,HIGH);
}
else
{
digitalWrite(8,LOW);
}