“Microduino-Joypad-Standard Angry Birds”的版本间的差异
(Created page with "{| style="width: 800px;" |- | ==Outline== Here we adopt Microduino-Joypad-Game to play Angry Birds on the computer. ==Principle== We adopt [Microduino-CoreUSB]] to simulate a...") |
853387039@qq.com(讨论 | 贡献) (→Bill of Material) |
||
第15行: | 第15行: | ||
|[[Microduino-CoreUSB]]||1||Core board | |[[Microduino-CoreUSB]]||1||Core board | ||
|- | |- | ||
− | |Microduino-Joypad- | + | |Microduino-Joypad-Standard ||1||Remote control |
|} | |} | ||
2014年11月22日 (六) 06:28的最新版本
OutlineHere we adopt Microduino-Joypad-Game to play Angry Birds on the computer. PrincipleWe adopt [Microduino-CoreUSB]] to simulate a keyboard. By Microduino-Joypad-Game, we can simulate keys of a computer mouse and play the game. Bill of Material
Download
Code: #include <Joypad.h>
int mouseX,mouseY,xValue,yValue;
boolean Joy_sw,Joy1_sw;
boolean sw_l,sw_r;
void setup()
{
Serial.begin(9600); // initialize serial communication with your computer
Mouse.begin(); // take control of the mouse
Keyboard.begin();
delay(2000);
}
void loop()
{
xValue = Joypad.readJoystick1X(); // read the joystick's X position
yValue = Joypad.readJoystick1Y(); // read the joystick's Y position
sw_l=Joypad.readButton(CH_SWITCH_L);
sw_r=Joypad.readButton(CH_SWITCH_R);
Joy_sw=Joypad.readButton(CH_JOYSTICK_SW);
Joy1_sw=Joypad.readButton(CH_JOYSTICK1_SW);
if(sw_r==true)
{
mouseX = map( xValue,-512, 512, 15, -15); // map the X value to a range of movement for the mouse X
mouseY = map( yValue,-512, 512, -15, 15); // map the Y value to a range of movement for the mouse Y
Mouse.move(mouseX, mouseY, 0); // move the mouse
if(Joy_sw==true)
Mouse.release(MOUSE_LEFT);
else
Mouse.press(MOUSE_LEFT);
if(Joy1_sw==true)
Mouse.release(MOUSE_RIGHT);
else
Mouse.press(MOUSE_RIGHT);
delay(30);
}
}
Debugging
Microduino-Joypad_Getting_start
Video |