Engineering Project

Hello. Welcome to this instructable. AS my first time using this, I have created a musical code that works by a sound sensor taking in music and playing it's beats through light up LEDs. In this instructable, I will show and document my creation and how to make one of your own.

Step 1: 1. What Will You Need?

The project will require your a Raspberry Pi 3 with Python 3 code software. Other then that, you will also need:
10x Blue jumper wire cables (gpio)

5x Black jumper wire cables (ground)

1x Red jumper wire cable (Power)

1x Raspberry Pi 3
2x Buttons

3x Male to Female jumper wire cables (Specifically red, black, and yellow)

8x LED's

8x 330 ohm resistors

2x Breadboards

1x T-Cobbler

1x Sound Sensor

Step 2: 2. Setting It Up on the Breadboard

A pretty hard part to say the least, but also the most engaging if you are passionate.
Although many of the pins are to be connected in different places depending on what you do, here is a guide on how to organize your wires and what goes where:

Put the T-Cobbler on the top of the breadboard (Vertically) and insert all of it's pins inside. Then connect your T cobbler to the Raspberry Pi 3, and make sure the Pi is connected to it's sources (Monitor, HDMI, Mouse, Keyboard, WiFi, SD card, main power). Connect the second breadboard to the first via the side ports of each breadboard. The breadboard on the left will be called left breadboard for now, and the right will be right breadboard.
- The blue wires will go into the GPIO ports on the Breadboard, and the T-Cobbler tells you where they are.

- The black wires will go into the ground ports, labelled GND on the T-Cobbler. 3 of the black wires will go into the negative lanes on the breadboards, in which they have 2 each (one will be unused).

- The red wire will be going into the left lane of the left breadboard, in the positive section.

- The buttons can go anywhere, but they will be needing a GPIO pin (blue wire) and a ground pin connected to a negative lane (black wire).
Note: There are many GPIO ports on the T-Cobbler. For example, one button will have a blue wire connected to GPIO4.

- The 8 LED's can be connected anywhere. The anode leg, or the longer leg, will be connected to a GPIO pin (blue wire). This means the in on slot the anode leg will be in the breadboard slot and the GPIO pin will be in a slot BESIDE that anode leg. The cathode leg, or the shorter leg, will have to be connected with a 330 ohm resistor beside the cathode leg. One pin of the 330 ohm resistor will be beside the cathode while the other pin will be connected in the negative lanes of any breadboard.

- The sound sensor has 3 pins attached to it: GND, SIG, and VCC. Take a black male to female jumper wire. Attach the male part to a negative lane on the breadboard (Which should have a black wire connected to ground) and the female part on the sound sensor's pin labelled "GND". Take a red male to female jumper wire. Attach the male part to the powered positive lane from earlier and the female part on the sound sensor's pin labelled "VCC". Finally, take the yellow male to female jumper wire. Attach the male part to an empty GPIO slot on the breadboard with the T-Cobbler and the female part on the sound sensor's pin labelled "SIG".

You should be finished. Your final result should look like the image shown

Step 3: 3. Setting Up Your Code

2 codes have been posted above. The first 2 are one code. Why so much code under while true? That is a musical beat of a song in the next step.

Step 4: 4. Choosing the Music

You can use speakers or your phone for this. In my example, I used a song called Megalovania from the video game Undertale, by Toby Fox. What I did was time each beat of the music using a timer app, where each beat I heard, I would press a lap button on my phone to each beat. This helps me with my sleep commands in the code.

Step 5: 5. Import the Code

The hardest part is here, implementing the code. Now that you have your timings on your phone, you can use the sleep commands to implement what LED turns on and off to the beat of the music.

For example:
LED1.on()

sleep(0.31)

LED1.off()

LED2.on()

sleep(0.21)

LED2.off()

Step 6: You Should Be Done!

I have given my project on top. There are mistakes, but it works well. Thank you.

Share

    Recommendations

    • Paper Contest

      Paper Contest
    • Epilog X Contest

      Epilog X Contest
    • Warm and Fuzzy Contest

      Warm and Fuzzy Contest

    Discussions

    0
    None

    Great first instructable. Thanks for sharing with the community.