查看“Microduino-Joypad-Standard Angry Birds”的源代码
←
Microduino-Joypad-Standard Angry Birds
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| 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 keyboard. By Microduino-Joypad-Game, we can simulate keys of a computer mouse and play the game. ==Bill of Material== *Microduino Equipment {|class="wikitable" |- |Module||Number||Function |- |[[Microduino-CoreUSB]]||1||Core board |- |Microduino-Joypad-Game ||1||Remote control |} ==Download== *Library file download:https://github.com/wasdpkj/libraries; **You will need:_01_Microduino_TFT and _08_Microduino_Shield_Joypad. Decompress the downloaded library file to libraries of Arduino IDE and then restart IDE compiler. Code: <source lang="cpp"> #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); } } </source> ==Debugging== *Step 1: Prepare Microduino-Joypad-Game and you can refer to: [[Microduino-Joypad_Getting_start]] *Step 2: Stack [[Microduino-CoreUSB]] on the panel of Microduino-Joypad-Game; *Step 3: Download libraries and codes needed and then update the libraries to the compiler. 【[[Install Arduino IDE Microduino Program Library Support Package]]】 *Step 4: Compile the code and choose the right board (Microduino-CoreUSB) and COM port for download. *Experience: **Open the game **Start the switch on the right top and control. **Simulate the right joystick as the mouse. **The left joystick as the left button of the mouse and the right joystick as the right button. *Control the left joystick to catch the bird and the right joystick to move around and shoot. ==Video== http://v.youku.com/v_show/id_XNzM3NTA1NzQw.html |}
返回至
Microduino-Joypad-Standard Angry Birds
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息