Académique Documents
Professionnel Documents
Culture Documents
Coding Arduino
That's basic stuff too. Copy this code inside the Arduino IDE;
compile it and upload it to your Arduino board.
1. /*
2. FGFS Pushbutton Input
3. Reads a digital input on pin 7, prints the result
4. to the serial port
5.
6. This example code is in the public domain.
7. */
8.
9. void setup() {
10. Serial.begin(9600);
11. pinMode(7, INPUT);
12. }
13.
14. void loop() {
15. int sensorValue = digitalRead(7);
16. Serial.println(sensorValue);
17. }
[Get Code]
We are setting the serial communication speed at 9600bps
here, it's a commonly supported speed over any serial
communication. Not very fast but fast enough. We could
crank it up in the future when higher data transfer rates will
be usefull. As of now, it's enough.
<?xml version="1.0"?>
<PropertyList>
<generic>
<input>
<line_separator>carriagereturn</line_separator>
<var_separator>,</var_separator>
<chunk>
<name>GearDown</name>
<node>/controls/gear/gear-down</node>
<type>bool</type>
</chunk>
</input>
</generic>
</PropertyList>
Starting FlightGear
Now everything is ready go. Arduino is running the code and
sending zeroes and ones over the serial
connection, FlightGear's protocol file has been saved
and FlightGear's command line option has been entered.
Side notes
Create the custom protocol file before running
the FlightGear Wizard otherwise it will not display the newly
created protocol file in its list. That's because it scans the
protocol directory only when it starts up. In this case, simply
close the wizard and start it again so that it scans the
protocol directory with the new files inside.