Thursday, November 1, 2018

MicroBit Light Sensor Instrument

I dove into this project with the idea of using the speaker add-on that allows the Microbit to play sounds with a little more elegance than using alligator clips and a stereo jack.

I have used micro-controllers as musical instruments before, but never with the Microbit so I was a little unsure on how I wanted to use it.

I decided on viewing the Microbit through the lens of a student, and concentrated less on what I was making but how I was using the tools to create my project.

I started by cruising the music project lists on the website before clicking on this guitar-type thing that had a few different projects within the instrument. I liked the way the light sensor tone production project looked and started following the tutorial.

It was not very hard to replicate the project. The drag and drop code blocks were similar to scratch so it was easier to try and find the right blocks to use(compared to the first time using Scratch).

When I ran the code with the light sensor, I noticed a few things:
     1. I need to calibrate the code to the space I am using it in.
     2. It seemed very sensitive.
     3. The sound does not stop.

I then was inspired to find solutions to these observations by changing the code to better suit my vision.

Step 1: Calibration

I could adjust the scale that was graphed by the  Microbit to get a better feel on how much light was 255 and how much light was 20 and all the differences in between.

Step 2: Limit available notes

I wanted to be in control of what note was being played so I decided to make the amount of notes availible to be played less. Specifically just 6 notes, a pentatonic scale C-D-F-G-A-C. I then made some code blocks that made the microbit play a certain note if the light level was between two numbers.


Step 3: User controlled sound

This was the most simple of the solutions. All I had to do was replace the "Forever" block with the "When A button is pressed". Boom! now I have a user, controlled light sensitive instrument!

Here is the finished code:
Video of the Microbit:

No comments:

Post a Comment