Wheel Beats
Project page for the Wheel Beats group in 4180. Group Members: Drew Boatwright, Jeff Gabriel, Lucy Lenhardt, Himanshu Pandey
Project Goals:
To develop essentially a drum kit that is applied to the steering wheel of a car, so one can play additional drum samples while listening to music on the road. *DISCLAIMER* Do not use while operating a vehicle.
Parts Used:
- Mbed
- 8x Force Sensitive Resistor Sensors https://www.sparkfun.com/products/9376
- Audio Jack Breakout https://www.sparkfun.com/products/8032
- SD Card breakout
- Steering Wheel
- Battery Pack Power Source
- Analog-to-Digital Converter (MCP3208) http://www.microchip.com/wwwproducts/Devices.aspx?product=MCP3208
- Attempted Bluetooth Module
Work Involved:
- Required work on the wav_player library to allow sound output through PWMOut rather than AnalogOut.
- Additional research in ways of interrupting the playing of wav files and adding wav files together.
- Utilizing the Auxiliary breakout module
- Increase SD Card Frequency to 25Mhz
Video
Project Code
Import program4180_FDP_ADC
See commit words
Code
#include "mbed.h" #include "SDFileSystem.h" #include <wave_player.h> #include <stdio.h> SPI spi(p11, p12, p13); // mosi(out), miso(in), sclk(clock) DigitalOut cs(p14); // cs (the chip select signal) Serial pc(USBTX, USBRX); // tx, rx ( the usb serial communication ) SDFileSystem sd(p5, p6, p7, p8, "sd"); PwmOut PWMout(p21); wave_player waver(&PWMout); FILE *wave_file; int main() { // Setup the spi for 7 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(7,0); spi.frequency(1000000); // Set PWMout period PWMout.period(1.0/400000.0); // notify the user that we are starting with the ADC communication pc.printf("Starting ADC interaction\n\n\n"); // lets just do this forever while (1) { for (int i = 0 ; i < 5; i++){ // Select the device by seting chip select low cs = 0; // sending the 6 bits + 1 bit to ignore the null bit // coming from the device, so the data that is sent is 1100000 spi.write(0x60 + (i*4)); // now the device sends back the readings 12 bits, 7 bits at a time uint8_t high = spi.write(0x00); uint8_t low = spi.write(0x00); // shift out the right bits low = ( high << 5 ) | (low >> 2); high = high >> 3; // shift and or the result together int value = ( high << 8 ) | low; // and voila we have the value and we can print it for the user //pc.printf("sensor %d value = %u\n", i, value); switch (i){ case 0: if (value > 60 ) { //pc.printf("\tX\r"); wave_file=fopen("/sd/snare.wav","r"); pc.printf("sensor %d value = %u\n", i, value); waver.play(wave_file); fclose(wave_file); } break; case 1: if (value >60){ //pc.printf("\t\t\t\tX\r"); pc.printf("sensor %d value = %u\n", i, value); wave_file=fopen("/sd/tom.wav","r"); waver.play(wave_file); fclose(wave_file); } break; case 2: if (value > 210){ pc.printf("sensor %d value = %u\n", i, value); wave_file=fopen("/sd/highhat.wav","r"); waver.play(wave_file); fclose(wave_file); } break; case 3: if (value > 55){ pc.printf("sensor %d value = %u\n", i, value); wave_file=fopen("/sd/tiss.wav","r"); waver.play(wave_file); fclose(wave_file); } break; case 4: if (value > 60){ pc.printf("sensor %d value = %u\n", i, value); wave_file=fopen("/sd/kik.wav","r"); waver.play(wave_file); fclose(wave_file); } break; } // Deselect the device cs = 1; } // delay some time before reading again wait_us(100); } }
Please log in to post comments.