Joypad-Game-Tetris
From Microduino Wiki
Revision as of 09:17, 21 November 2014 by 1304410487@qq.com (talk) (Created page with "{| style="width: 800px;" |- | ==Outline== Use Microduino-Joypad-Game to play Tetris. ==Bill of Material== *Microduino Equipment {|class="wikitable" |- |Module||Number||Funct...")
ContentsOutlineUse Microduino-Joypad-Game to play Tetris. Bill of Material
DownloadTFT library:https://github.com/wasdpkj/libraries/tree/master/_01_Microduino_TFT Joypad lib.:https://github.com/wasdpkj/libraries/tree/master/_08_Microduino_Shield_Joypad Code: Debugging
Microduino-Joypad_Getting_start
if(Joypad.readButton(CH_SWITCH_R))
{
if(Joypad.readButton(CH_SWITCH_2)==0)
joyx=100;
else if(Joypad.readButton(CH_SWITCH_4)==0)
joyx=-100;
if(Joypad.readButton(CH_SWITCH_1)==0)
joyy=-100;
else if(Joypad.readButton(CH_SWITCH_3)==0)
joyy=100;
else if(Joypad.readButton(CH_SWITCH_1)==1&&Joypad.readButton(CH_SWITCH_2)==1&&Joypad.readButton(CH_SWITCH_3)==1&&Joypad.readButton(CH_SWITCH_4)==1)
{
joyx=0;
joyy=0;
}
}
else
{
joyx = map(Joypad.readJoystickX(), -280, 300, 100, -100);
joyy = map(Joypad.readJoystickY(), -300, 230, -100, 100);
} Button control is the default setting by turning the left and the right switches to the top. So, the opposite operation is gravity induction control. Users can change the setting according to personal needs.
Joypad.motor(0);//Close
Joypad.motor(X);//0-255 Vibration can be adjusted
digitalWrite(speak,LOW);//Close
digitalWrite(speak,HIGH);//Open Step 5: Compile the code and select the right board and COM port for download. After that, you can start to play. The sore is on the right top. Users can also try to use gravity induction control according to individual needs. |