I have 4 engine instruments in my flightsim that require a 0 to 70Hz signal to operate. The code below functions perfectly with one gauge. How if possible do I add the other 3? From what I have read only 1 tone can be output at one time. I hope that being new I am missing something obvious to make this work. Has to be a square wave from 0 to 70Hz which corresponds to 0 to 100% rpm on my engine guages. Here is the working code for one, Thanks for any advice,
Code:
long previousMillis = 0;
long interval = 500; //anything less and it doesn't work. 1000 had to much delay in gauge update rate
FlightSimFloat eng1N1; //Engine 1 RPM in percent 0-100
void setup() {
eng1N1 = XPlaneRef("sim/cockpit2/engine/indicators/N1_percent[0]");
}
void loop() {
FlightSim.update();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
float rpm = map(eng1N1, 20, 100, 14, 70);
tone(23, rpm);
}
}