Skip to the content.

Air Basketball

2023 Fall NTU embedded system lab final project.

Project Structure

.
├── source
│   ├── main.cpp
├── websocket
│   ├── socket-server.py
│   ├── canva.py
├── server
│   ├── index.py
├── airbasket
│   ├── pages
│   │   ├── index.js
│   ├── hand-pose-detection
│   │   ├── index.js
├── README.md

Project Description

We use the STM32L4 Discovery Kit IoT Node to develop an air basketball game. The player can use his/her hand to simulate the shooting process. The accelerometer on the board will collect the data and send it to the server. The server will use the data to simulate the shooting process and send the result back to the board. The board will use the result to control the buzzer to notify the player if goal or not.

For better user experience, we also develop a web page to show the result of the simulation. A user has to ask a ball to shoot on the web page through the hand pose detection.The web page will show the position of the ball and the result of the simulation. A user can also change the difficulty level on the web page. The difficulty level will be sent to the board and the board will change the led mode to indicate the difficulty level.

How to Start

  1. Open servers

    1. Open flask http server
      1. Open the folder “eslab-final-project”
      2. cd server
      3. python index.py
    2. Open stm socket server
      1. Open the folder “eslab-final-project”
      2. cd websocket
      3. python socket-server.py
  2. Open Mbed Studio

    1. import the program from URL https://github.com/ARMmbed/mbed-os-example-sockets
    2. Set the “use-tls-socket” to false in mbed_app.json
    3. Modify the AP’s SSID and password in mbed_app.json
    4. Download the driver “BSP_B-L475E-IOT01” and add it to the project
    5. Add the necessary libraries to the project
    6. Compile and flash the program to the board
    7. Plug the buzzer to the board (D11)
    8. (Optional) Use charger to power the board instead of connecting to the computer
  3. Open the web page

    1. option1: use deployed frontend
      1. open air-basketball on your browser and allow the camera access
      2. choose the mode (easy, normal, hard) and click the “Start game” button
      3. use your hand to ask a ball to shoot
      4. the result of the simulation will be shown on the web page
    2. option2: use local
      1. Open the folder “eslab-final-project”
      2. cd airbasket
      3. yarn
      4. set url in .env.development to your server url
      5. yarn dev

Motivation

Since every people who love basketball would like to shoot the ball everywhere, as if they were NBA players, and hit the 3-pt shot, so we want to make the dream come true. It can also improve the shooting position and angles.

Technologies Used

Websocket

Digital Signal Processing (DSP)

BSP (Board Support Package)

Semaphores

PWM (Pulse Width Modulation)

Multi-threading

VPython

Next.js

Flask

Vercel

Hand Pose Detection

New Features (after Demo)

Reference