Maze Game to Control With Smartphone

by アロー明和レーシング in Circuits > Remote Control

1983 Views, 20 Favorites, 0 Comments

Maze Game to Control With Smartphone

maze0.png
Maze game to control with smartphone. Scene 1
Maze game to control with smartphone. Scene 2

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.

Hardware Preparation

servo_folder.jpg
mazemake.jpg
maze2_servo.jpg
  • 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)

Connection

pin.png

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.

Setting Up Raspberry Pi

nodered.png

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.

Downloads

Execution

maze1.jpg
maze2.jpg

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.

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.