Ok. A couple of things. Have a look at the Arduino configuration post that is pinned at the top of the Race Coordinator forum page. It is everything I have managed to find on RC and Arduino; and it also explains how I programmed the sketch for my requirements. It is NOT a masterclass in programming but it was how I got it to work. Dave tells me that there are several things wrong with it and he's the expert in it all, so if he pitches in with something, you know that it is correct.
Having looked at the sketch again, there is a section for configuration for fuel. This is the section:
case extFuel:
// Fuel
#ifdef WITH_FUEL_STUTTER
{
SERIAL_PRINTLN("*Got extFuel");
byte lane = inBuffer[2] TXT_TO_INT_CONVERSION;
if (lane < FUEL_NUM_LANES) {
byte level = inBuffer[3] TXT_TO_INT_CONVERSION;
SERIAL_PRINT("Got fuel for lane ");
SERIAL_PRINT(lane);
SERIAL_PRINT(" and value ");
SERIAL_PRINTLN(level);
if (level == 0 && !fuelOOF[lane]) {
// Assume power is on, setting time to 0 will cause it
// to turn off
fuelOOF[lane] = true;
fuelTimeUs[lane] = 0;
fuelPowerOn[lane] = true;
}
else if (level > 0) {
// This will turn power back on if its not already
fuelOOF[lane] = false;
}
}
}
#endif
break;
So, my reading of this is that you should be able to turn on your specific LEDs based on the value of 'level's. I'm guessing that those values range from 0 to 255, so, every time 'level' drops in value by 25(ish) another light goes off (or on). Eg if level == 255, then all 10 LEDs are lit; if level == 230, then light only 9, etc.
You should be able to figure out the way to light the correct LEDs from the code in the RaceState section, along the lines of this:
case 2:
// Initial countdown Start
{
lightOn = false;
int LED = 4 - (inBuffer[3] TXT_TO_INT_CONVERSION);
if (LED < 0)
{
for (int i = 0; i < 5; i++)
{
rgbLedStrings[0].leds = CRGB::Black;
rgbLedStrings[1].leds = CRGB::Black;
}
}
if (LED == 4)
{
rgbLedStrings[1].leds[4] = CRGB::Red;
rgbLedStrings[0].leds[4] = CRGB::Red;
}
if (LED == 3)
{
rgbLedStrings[1].leds[3] = CRGB::Red;
rgbLedStrings[0].leds[3] = CRGB::Red;
}
if (LED == 2)
{
rgbLedStrings[1].leds[2] = CRGB::Red;
rgbLedStrings[0].leds[2] = CRGB::Red;
}
if (LED == 1)
{
rgbLedStrings[1].leds[1] = CRGB::Red;
rgbLedStrings[0].leds[1] = CRGB::Red;
}
if (LED == 0)
{
rgbLedStrings[1].leds[0] = CRGB::Red;
rgbLedStrings[0].leds[0] = CRGB::Red;
}
}
break;
For the colour of the lanes, that (I think!) should be a lot simpler, as these will not change and are not dependent on any information coming from Race Coordinator. It should be a case of telling the Arduino which LEDs directly to light and with which colour. Eg if lane ==1 {rgbLedStrings[1].leds[10,11,12....19] = CRGB::Blue;} says, if lane 1, then set LEDs 10 to 19 to blue.
Have a look at this first and come back to me with any specific questions you have because I know how difficult it can be trying to interpret things that other people say, when they are generalising. I can't test this myself, as I don't have an analogue setup but I can perhaps give you some code and more pointers.
Connal