Introduction: Maze Game to Control With Smartphone

Picture of Maze Game to Control With Smartphone

Maze game to control with smart phone.

The maze moves according to the slope of the smartphone.

First of all, please see the video.

Motion image

1. Raspberry Pi is a Websocket server.

2. The smartphone is a Websocket client.

3. The smartphone sends the tilt data to Raspberry Pi.

4. Raspberry Pi controls the servo according to the inclination data.

Step 1: Hardware Preparation

Picture of Hardware Preparation
  • Servo and servo folder
    Servo uses Tower-pro SG90. Please refer to the URL for details. 3D data can also be downloaded.
    https://www.thingiverse.com/thing:746116
  • Maze game (light stuff, made with styrene board)
  • Ball (Light stuff.)
  • Raspberry Pi (using Raspberry Pi 3B)
  • Smartphones (Prepare new browsers as much as possible.Safari Chrome Firefox)

Step 2: Connection

Picture of Connection

1. Connect the upper line to GPIO 12 (32 PIN).

2. Connect the lower line to GPIO 18 (12 PIN).

3. Align the direction of the servo.

Step 3: Setting Up Raspberry Pi

Picture of Setting Up Raspberry Pi

1. GPIO

Chattering is done with Rpi.GPIO installed in the standard.
Therefore, I will install pi-gpiod. This is because the PWM output is stable.

Installation method

sudo apt-get install pigpio python-pigpio python3-pigpio
http://abyz.me.uk/rpi/pigpio/index.html

Start the daemon.

sudo pigpiod

2. Node-RED

Install the library for pi-gpiod.
https://flows.nodered.org/node/node-red-node-pi-gpiod

Install the dashboard library for debugging.
https://flows.nodered.org/node/node-red-dashboard

3. Creating flow

Please import (Copy & Paste) the following files to Node-RED. Deploy when you can copy normally.

Step 4: Execution

Picture of Execution

1. Connect with a smartphone

Please connect your smartphone to WIFI on the same segment. Open the web browser and enter the IP address of Raspberry Pi.

fig. http://192.169.1.000:1880/cam

2. Move the maze according to the slope of the smartphone. Let's keep slow motion.

Step 5: To the End

As it reacts sensitively to the movement of the smartphone, please correct the program and lower the sensitivity.

In that case please modify the function node of Node-RED.

Happy instructables.

Comments

About This Instructable

583views

16favorites

License:

Bio: I like 100 yen shop. I like home improvement center. I like IKEA. I like motor sports.
More by 明和自動車:Maze Game to Control With SmartphoneElectronic Drum With AB-Shutter3Caster Mounting Example of Water Pipe Furniture
Add instructable to: