Joypad-Game-Tetris

From Microduino Wiki
Revision as of 08:44, 13 September 2016 by Fengfeng (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 1
Microduino-Joypad-teril.jpg

Download

TFT library: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_01_Microduino_TFT_ST7735 Joypad lib: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_08_Microduino_Shield_Joypad Code: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Joypad/Microduino_JoyPad_Game/Microduino_JoyPad_teril

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.