Arduino Esplora Flight Simulator
by akellyirl in Circuits > Arduino
8538 Views, 28 Favorites, 0 Comments
Arduino Esplora Flight Simulator
Control the Flight Simulator option of Google Earth using the Accelerometer of the Arduino Esplora.
Fly virtually around the world; tilting the Accelerometer forward, back, left and right to control the Plane's Pitching and Banking.
If you don't have Google Earth on your PC download it from here:
http://www.google.com/earth/index.html
BTW, you if you don't want to agree to Google Chrome becoming your Default Browser UNCHECK the box at the License Agreement stage.
Fly virtually around the world; tilting the Accelerometer forward, back, left and right to control the Plane's Pitching and Banking.
If you don't have Google Earth on your PC download it from here:
http://www.google.com/earth/index.html
BTW, you if you don't want to agree to Google Chrome becoming your Default Browser UNCHECK the box at the License Agreement stage.
You Will Need
Arduino Esplora.
You can download the required code here.
Esplora Code
/* Esplora Google Earth Flight Sim This sketch shows you how to read the values from the accelerometer to control your Mouse. Mouse is active/inactive on SWITCH_4 Press. Use with Google Earth Flight Sim Mode This example is in the public domain. */ #include <Esplora.h> int state = 1; int state_old = 1; int mode = 0; int xAxis, xAxis_old = 0; int yAxis, yAxis_old = 0; int zAxis, zAxis_old = 0; void setup() { } void loop() { state_old=state; state = Esplora.readButton(SWITCH_4); if (state_old && !state) { mode = !mode; if (mode) { Mouse.begin(); // take control of the mouse Keyboard.begin(); Mouse.press(); // Click to use Mouse Control in Sim delay(100); Mouse.release(); } else { Mouse.end(); Keyboard.end(); } } // Throttle ++ if (!Esplora.readButton(SWITCH_3)) { Keyboard.press(KEY_PAGE_UP); delay(100); Keyboard.releaseAll(); } // Throttle -- if (!Esplora.readButton(SWITCH_1)) { Keyboard.press(KEY_PAGE_DOWN); delay(100); Keyboard.releaseAll(); } xAxis_old = xAxis; yAxis_old = yAxis; xAxis = Esplora.readAccelerometer(X_AXIS); // read the X axis yAxis = Esplora.readAccelerometer(Y_AXIS); // read the Y axis int delta_x = xAxis-xAxis_old; int delta_y = yAxis-yAxis_old; if (mode) Mouse.move(-5*delta_x, 2*delta_y, 0 ); delay(10); // wait half a second (500 milliseconds) }
Enjoy
1. Open Google Earth
2. Start the Flight Simulator mode (Tools-> Enter Flight Simulator) or (Ctrl+Alt+A)
3. Best to Select the SR22 Aircraft to start with. It's easier to control.
4. Centre your mouse in the Google Earth Screen
5. Press SWITCH 4 on the Esplora to Take Control of the Mouse
6. Tilt your Arduino to Control the Plane. Backwards to Climb, Forwards to Descend etc...
KeyBoard Controls:
PgUp : Speed ++ (or SWITCH 1)
PgDn : Speed-- (or SWITCH 1)
Space: Pause
More details in Google Earth Help
7. Press SWITCH 4 on the Esplora again to Relinquish control of the Mouse.
Have fun!!
2. Start the Flight Simulator mode (Tools-> Enter Flight Simulator) or (Ctrl+Alt+A)
3. Best to Select the SR22 Aircraft to start with. It's easier to control.
4. Centre your mouse in the Google Earth Screen
5. Press SWITCH 4 on the Esplora to Take Control of the Mouse
6. Tilt your Arduino to Control the Plane. Backwards to Climb, Forwards to Descend etc...
KeyBoard Controls:
PgUp : Speed ++ (or SWITCH 1)
PgDn : Speed-- (or SWITCH 1)
Space: Pause
More details in Google Earth Help
7. Press SWITCH 4 on the Esplora again to Relinquish control of the Mouse.
Have fun!!