So, we’ll need to convert our accelerometer values to be all positive. The tempo is the number of milliseconds that the tone lasts for, and these values are always positive (1000 milliseconds = 1 second). We know that acceleration uses values from -1023 to 1023. Now let’s change the tempo based on the motion of BMO. Step 4: Change music tempo based on motion From the ||input:INPUT|| Toolbox drawer, drag the ||input:light level|| block onto the Workspace and drop it into the first slot of the ||math:0 + 0|| block replacing 0.ayTone(0 + 0, music.beat(BeatFraction.Half)) From the ||math:MATH|| Toolbox drawer, drag out an addition ||math:0 + 0|| operator block onto the Workspace and drop it into the first slot of the ||music:play tone|| block replacing Middle C.We know that 300 MHz is about the frequency for the Middle D note, so let’s add 300 to our light level values. We want to map the light level values (0 - 255) to frequency values. The Adafruit Circuit Playground Express can play notes that are represented as frequency values (in Hertz).Īlso, the Adafruit Circuit Playground Express measures how light or dark it is through a light level sensor (0 = completely dark and 255 = bright light). We want to change the pitch, or the note that’s being played, based on the light level (darker makes a lower note and brighter makes a higher note). Step 3: Change music pitch based on light level Notice that this ||music:play tone|| block contains 2 fields – one for the note pitch, and one for the note duration. From the ||music:MUSIC|| Toolbox drawer, drag out a ||music:play tone|| block onto the Workspace and place in this ||loops:forever|| block.Press the speaker icon under the Simulator to mute. Note! You may want to take this opportunity to mute your computer or the Simulator.From the ||loops:LOOPS|| Toolbox drawer, drag out another ||loops:forever|| block onto the Workspace.Notice that a Console button also appears under the Simulator – if you click that you’ll see a graph view of the accelerometer values! Try moving your mouse left and right over the Simulator to see how the lights change as the Adafruit Circuit Playground Express moves. From the ||input:INPUT|| Toolbox drawer, drag out an ||input:acceleration|| block and drop into the ||light:graph|| block replacing the 0.From the ||light:LIGHT|| Toolbox drawer, drag out a ||light:graph|| block to the coding Workspace and drop it into the |loops:forever|| block.Name your Project as MusicBox (note – you don’t need to click the Save button, just type the name).We will use the lights on our Adafruit Circuit Playground Express to show the values of the accelerometer when it’s tilted left and right (along the X axis). When the Adafruit Circuit Playground Express is laying flat, face up: X = 0, Y = 0, Z = -1023. It uses values from negative -1023 to positive 1023. The accelerometer is right in the middle of the Adafruit Circuit Playground Express, under the RESET button. The motion sensor, also called an “accelerometer”, measures motion (also called acceleration) along 3 dimensions: ayTone(262, music.beat(BeatFraction.Half)) Step 1: Make an animation using the Motion Sensor CodeĬode BMO to play music – based on the how you’re moving him, and how much light he’s in. Be careful not to tape over the On/Off switch.Ĭongratulations! You have made your own BMO! Tape the battery pack onto the back of BMO. Place the tape on the back of the Adafruit Circuit Playground Express and stick onto the top of BMO.Īttach the wire from the battery pack to the Adafruit Circuit Playground Express. Use a small piece of tape and roll it inside out to form a loop so that the sticky side is on the outside. Step 5: Attach the Circuit Playground Express and battery pack Insert the batteries into the battery pack. Using one end of the scissors, poke holes in places on the box where arms and legs should be. Using blue pipe cleaners, cut or bend 4 pieces to a good size for BMO’s arms and legs. Using a black marker, make sure to add BMO’s side label and lines for his other slots. Color in BMO’s face, and controls using colored markers, pencils or crayons.Ĭut out and glue or tape the face and controls onto the blue box. On the piece of white paper, draw outlines of BMO’s face and controls. Step 2: Draw and attach BMO’s face and details Use blue construction paper and tape/glue, or blue paint to cover the outside of the box completely in blue. Blue construction paper (or blue paint).Adafruit Circuit Playground Express Base Kit.Collect the materials in the list before starting your project Make.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |