was able to compile this latest sketch but haven't had a chance to put it in the board yet. here it is if anyone wants to give it a try. we won't know if my logic all works until it's on a board but having it compile is a good step forward indicating my arduino is coming along.
if/when it works i'll have completed boards in my webshop for purchase.
/*
LED control using jDrones ioBoard and inputs from
RC receiver (PWM)
PWM signal pulses are measured using 'pulseIn' statement
Conditional statement looks at PulseIn value and determines
*****illumination pattern of LED outputs*****
illumination alternating left/right indicates manual control
coordinated heartbeat indicates GPS position hold
rapid flashing indicates come-home mode active
Created 26 March, 2012
By Bartman with help from the Arduino community.
This code is in the public domain at
http://www.multirotorforums.com/sho...roller-jdrones-ioBoard-hack&p=92148#post92148
*/
void setup() {
// pin numbers for inputs and outputs
unsigned long Duration;
unsigned long lastgood1;
int rxGPSmode = A1; // input pin using GPS mode channel from Rx
int ledPin1 = 2; // pin for left LED output, PWM enabled
int ledPin2 = 3; // pin for right LED output, PWM enabled
int ledCounter; // counter variable used to loop LED patterns
int ledBrightness; // brightness variable for heartbeat pattern
int fadeAmount = 25; // factor used to build light intensity in Heartbeat pattern
pinMode (rxGPSmode, INPUT); // initialize Rx connection pin as in INPUT
pinMode (ledPin1, OUTPUT); // initialize the LED pins as outputs
pinMode (ledPin2, OUTPUT);
}
void loop()
{
static int Duration;
static int rxGPSmode;
static int lastgood1;
static int ledPin1;
static int ledPin2;
static int fadeAmount;
static int ledCounter;
static int ledBrightness;
Duration = pulseIn(rxGPSmode, HIGH, 20000); //read GPS mode channel
if (Duration == 0) {Duration = lastgood1;} else {lastgood1 = Duration;}
if (Duration < 100){
// alternating arms flash slowly----->GPS off
digitalWrite(ledPin1, HIGH); // turn the ledpin1 ON (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(ledPin1, LOW); // turn the ledpin1 OFF by making the voltage LOW
delay(100); // brief delay, to make blinking appear uniform throughout subroutine
digitalWrite(ledPin2, HIGH); // turn ledpin2 ON
delay(1000); // wait for a second
digitalWrite(ledPin2, LOW); // turn ledpin2 OFF
}
else if (Duration > 1200)
{
// LEDs flash quickly for three seconds then exit loop to recheck conditional
// GPS come home mode active
//
for (int ledCounter = 0; ledCounter < 9; ledCounter = ledCounter +1) {
ledPin2 = ledPin1; // ledpin2 set equal to ledpin1 to coordinate illumination pattern
digitalWrite(ledPin1, HIGH); // both LED pins turn on
delay(300); // wait 1/3 second
digitalWrite(ledPin1, LOW); // both LED pins turn off
delay(100); // wait 1/3 second
}
}
else
{
// heartbeat pattern, GPS PH active
ledPin2 == ledPin1;
for (int ledBrightness = 0; ledBrightness <= 250; ledBrightness = ledBrightness + fadeAmount) {
analogWrite(ledPin1, ledBrightness);
}
analogWrite(ledPin1, 250);
delay(250);
digitalWrite(ledPin1, LOW);
delay(250);
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
}
}