Skip to content

source code for the SSCS Arduino Contest 2023 project

Notifications You must be signed in to change notification settings

brettyang02/Arduino_music

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino project: Jam Helper

Elizabeth Tyra Sumual, Shuntaro Wakamatsu, Brett (Jiaxin) Yang

University of Toronto - 2023

Overview:

This project consists of an Arduino-based distance sensing system that interacts with a Python-based note player to create a musical experience based on the distance measured by an ultrasonic sensor. The system reads input from a keypad to set parameters like delay time (speed) and operating mode. It then sends the collected data (delay, distance, and mode) over the serial port to a Python outer shell, which further triggers the Python code responsible for playing the notes and drum sounds.

Components Required:

  1. Arduino board (e.g., Arduino Uno)
  2. Keypad module (4x4)
  3. Ultrasonic distance sensor (HC-SR04)
  4. Python packages: serial, re, time, subprocess, os, pygame, sys

How to interact with Jam Helper:

  1. connect all hardware components
  2. press * to start, again for pause/start
  3. change tempo by entering speed (60, 90, 120) and press #
  4. change mode (4/4 soft, 4/4 rock, 3/4, 12/8) by pressing ABCD

Code files: (~/REVEAL/)

Arduino code (REVEAL.ino)

The Arduino code handles interactions with the keypad and ultrasonic sensor. It reads input from the keypad to set the delay time and operating mode. The ultrasonic sensor measures the distance to an object, and this information, along with the delay time and mode, is sent to the Python outer shell via the serial port.

Python Outer Shell (shell.py):

The Python outer shell acts as an intermediary between the Arduino and the Python note player. It receives data (delay, distance, and mode) from the Arduino through the serial port. The outer shell then processes this data and triggers the Python note player based on the specified delay and mode. The Python outer shell uses multi-threading to handle note playing while maintaining a smooth interaction with the Arduino.

Python Note Player (play.py):

The Python note player is responsible for creating musical notes and drum sounds based on the received data from the outer shell. It uses the Pygame library to handle sound playback. The note player interprets the note, distance, and mode values and plays corresponding notes or sounds to create a musical experience. The note player supports different modes of operation, and it allows you to control the volume of each sound independently.

How to use:

Setup and Execution:

  1. Connect the Arduino to the hardware components (keypad, ultrasonic sensor, and servo motor) as described in the connections section of the Arduino code.
  2. Connect the Arduino board to the computer via a USB cable.
  3. Upload the Arduino code to the Arduino board using the Arduino IDE
  4. Close Arduino and install the required Python libraries (serial, pygame) for the Python Outer Shell and Python Note Player using pip.
  5. Run the Python Outer Shell (Python_Outer_Shell.py) on the computer. Ensure the correct serial port (e.g., 'COM3') is specified in the ser = serial.Serial('COM3', 9600) line.
  6. The Arduino will start reading input from the keypad and sending data to the Python Outer Shell.
  7. The Python Outer Shell will process the data and trigger the Python Note Player to play notes and drum sounds based on the received data.

Important Notes:

  • Ensure all hardware components are properly connected to the Arduino before uploading the code.
  • Serial port information can be found through Arduino IDE or Device Manager
  • Adjust the speed and mode settings as needed for your musical preferences.
  • The provided code is a basic example and may require further modifications or enhancements for specific use cases.

About

source code for the SSCS Arduino Contest 2023 project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •