GR-ADZUKI Special Project: Let’s Make a Ball Playing Game with S4A!


Using the S4A program, let's make a game with GR-ADZUKI as a game pad! Put an acceleration sensor on GR-ADZUKI and tilt it; you will be able to send the movement data for front, rear, right, and left to your computer.



You will need a GR-ADZUKI board, a USB cable (Micro B type), and an acceleration sensor KXSC7-2050.

Attach an acceleration sensor to GR-ADZUKI as follows. Be careful about its directions; attach it so that the printed characters X, Y, Z on the acceleration sensor match the ones A3, A4, A5 on the GR-ADZUKI board.


Use S4A. If needed, please refer to the GR-ADZUKI Fun with Scratch (S4A) project for installation instructions.

Loading a Sample Program

Reading a sample program for a ball playing game using S4A.

After download, select FileOpen from the menu of S4A for loading the file.

Load the file as shown, when GR-ADZUKI is recognized, press the green flag on the upper right. Then a game begins. When you put your hand over the illumination sensor on the GR-ADZUKI board, the ball will be thrown. When you tilt the board, a cat will move or jump. The speed of the ballfly changes depending on the movement speed of the cat, the score to hit an enemy becomes higher as speed is high.


Since the world is filled with games using Scratch, I'd like to talk a little about a cooperation part of GR-ADZUKI. The functions used with GR-ADZUKI are as follows.

Throwing a Ball

When a value of the illumination sensor on GR-ADZUKI, set as Analog2 in S4A, becomes below 100, send the message of “THROW” to the ball sprite and set the ball fly flag to 1. The ball sprite, received the message of “THROW”. Flies in speed that cat runs (defined as cat_ax in S4A ) at first, drawing a parabola. If the ball sprite falls to ground (Y-axis -100) or hit an enemy, set ball fly flag to 0. Repeat this.

Moving a Cat

Using a 3-axis acceleration sensor module put on GR-ADZUKI for the traverse or the jump of a cat. The three axis are as follows. As a characteristic of KXSC7-2050, output is 1.65V at acceleration 0. As in the GR-ADZUKI case, the value of the acceleration sensor is 1023 at 3.3V at the maximum, so the value of each axis will be 512 at half. Besides, the sensitivity of the sensor is 0.66V/g. As an analog value gains approximately 310 per 1V, it gains 204.8 (0.66 * 310) when a load is applied by 1g - gravity. Therefore, the value of the Z-axis, defined as Analog5 in S4A, becomes approximately 717 (512 + 205), with 1g load of gravity acceleration when a board is horizontal. In other words, when GR-ADZUKI is completely level, the value will be as follows. Analog3: 512, Analog4: 512, Analog5: 717. A value of Analog3 changes as acceleration of gravity increases in the X-axis direction when a board is vertical for the X-axis direction.

Using a value of X-axis, set as Analog3 in S4A, for the traverse of the cat. It calculates the amount of change from 512 when it is level, then the acceleration of the cat is assumed to be its integer number divided by 10.

Using Y-axis, defined as Analog4, for the jump of the cat. When a value becomes bigger than 600, a cat will jump in this program.

Recommendation to Put in a Case

Using GR-ADZUKI like a game pad this time, sometimes the electronic board may be broken by static electricity. Please refer as follows: The writer made a hole in a packing box with a cutter, so that it allows a USB cable connection without directly touching with hands.