Henju
04-23-2014, 08:03 AM
Hi ,
Having some issues with the coding
trying to use a potentiometer for the obs knob and translating that via mapping it, yet I cant seem to get it to work,
just the last part of the code
void INPUTS() // Simconnect codes and "Keys" section
{
Kstringnewstate = "";
for (int KpinNo = 8; KpinNo < 70; KpinNo++){
KpinStateSTR = String(digitalRead(KpinNo));
KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 8));
if (KpinStateSTR != KoldpinStateSTR)
{
if (KpinNo != 13){
if (KpinNo == 8 && KpinStateSTR == "0"){Serial.println ("C01");} //sets gear handle up
if (KpinNo == 9 && KpinStateSTR == "0"){Serial.println ("C02");} //sets gear handle down
if (KpinNo == 10 && KpinStateSTR == "0"){Serial.println ("C15");} //Decrements flap handle position
if (KpinNo == 11 && KpinStateSTR == "0"){Serial.println ("C14");} //Increments flap handle position
if (KpinNo == 12 && KpinStateSTR == "0"){Serial.println ("A02");} //Increments COM1sb by one MHz
if (KpinNo == 14 && KpinStateSTR == "0"){Serial.println ("A01");} //Decrements COM1sb by one MHz
if (KpinNo == 15 && KpinStateSTR == "0"){Serial.println ("A426543");} //Sets transponder code to 6543
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 360); // scale it to use it with the servo (value between 0 and 180)
{Serial.println ("A33") (val);
}
// Add more here but remember to change the figure in the next line down. (the 15)
if (KpinNo > 15){ //Change pinNo number to same as the highest one used for simconnect codes.(the 15)
Serial.print ("D");
if (KpinNo < 10) Serial.print ("0");
Serial.print (KpinNo);
Serial.println (KpinStateSTR);
}
}
}
Kstringnewstate += KpinStateSTR;
}
Kstringoldstate = Kstringnewstate;
}// end of INPUTS void
any help would be appreciated
Thanks
Henri
Having some issues with the coding
trying to use a potentiometer for the obs knob and translating that via mapping it, yet I cant seem to get it to work,
just the last part of the code
void INPUTS() // Simconnect codes and "Keys" section
{
Kstringnewstate = "";
for (int KpinNo = 8; KpinNo < 70; KpinNo++){
KpinStateSTR = String(digitalRead(KpinNo));
KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 8));
if (KpinStateSTR != KoldpinStateSTR)
{
if (KpinNo != 13){
if (KpinNo == 8 && KpinStateSTR == "0"){Serial.println ("C01");} //sets gear handle up
if (KpinNo == 9 && KpinStateSTR == "0"){Serial.println ("C02");} //sets gear handle down
if (KpinNo == 10 && KpinStateSTR == "0"){Serial.println ("C15");} //Decrements flap handle position
if (KpinNo == 11 && KpinStateSTR == "0"){Serial.println ("C14");} //Increments flap handle position
if (KpinNo == 12 && KpinStateSTR == "0"){Serial.println ("A02");} //Increments COM1sb by one MHz
if (KpinNo == 14 && KpinStateSTR == "0"){Serial.println ("A01");} //Decrements COM1sb by one MHz
if (KpinNo == 15 && KpinStateSTR == "0"){Serial.println ("A426543");} //Sets transponder code to 6543
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 360); // scale it to use it with the servo (value between 0 and 180)
{Serial.println ("A33") (val);
}
// Add more here but remember to change the figure in the next line down. (the 15)
if (KpinNo > 15){ //Change pinNo number to same as the highest one used for simconnect codes.(the 15)
Serial.print ("D");
if (KpinNo < 10) Serial.print ("0");
Serial.print (KpinNo);
Serial.println (KpinStateSTR);
}
}
}
Kstringnewstate += KpinStateSTR;
}
Kstringoldstate = Kstringnewstate;
}// end of INPUTS void
any help would be appreciated
Thanks
Henri