Joypad-Game-Tetris

来自Microduino Wikipedia
1304410487@qq.com讨论 | 贡献2014年11月21日 (五) 09:17的版本 (Created page with "{| style="width: 800px;" |- | ==Outline== Use Microduino-Joypad-Game to play Tetris. ==Bill of Material== *Microduino Equipment {|class="wikitable" |- |Module||Number||Funct...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Outline

Use Microduino-Joypad-Game to play Tetris.

Bill of Material

  • Microduino Equipment
Module Number Function
Microduino-Core 1 Core board
Microduino-USBTTL 1 Program download
Microduino-Joypad/zh 1
Microduino-Joypad-teril.jpg

Download

TFT 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

  • Step: Prepare Microduino-Joypad-Game and you can check:

Microduino-Joypad_Getting_start

  • Step 4: Open the program example
    • Switch the code of the joystick and the button control:
      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.

  • Vibration motor control:
Joypad.motor(0);//Close  
Joypad.motor(X);//0-255 Vibration can be adjusted
  • Buzzer
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.