Class 4 – A Sunlight Song Player

I’m working on a musical instrument that you can press onto your window. When the sunlight comes out, it plays a song such as “Here Comes The Sun” by the Beatles. I’m imagining it would take the shape of a sun as well.


Ultimately, you can turn the whole object on or off, set which song will be played when it is bright enough outside, and hear that tune once as you select it. For now, the light sensors are photo resistor cells. Later, I want to use a light sensor that I have from Adafruit. I also want it to be able to work in lighter or darker cities, such as Los Angeles or Seattle. This would mean telling it to read the average light in a room, to come up with a new threshold after which to play the tune.

For now, I’m focusing on what I can prototype quickly. Conveniently, my Intro to Fabrication class assignment is to make an enclosure. This is what I have in mind for now.



As for the code and circuits, there are several functions to sort out… ! Therefore, I’m iterating by focusing one function at a time. That way I can isolate the code for each function before I combine them all together.

To start with, I focused on the control panel & ability to play a song with a piezo. On the left you can see my control panel in the works. On the right is my work to play at least one song by pressing one button.

IMG_0001 2

On a successful note, I debugged a lot of code and realized I needed to level up to create a pushButtonCounter, so that the program can keep track of whether the button is on or off, and control another behavior at the same time, such as a light or eventually playing a song.

giphy_3 buttons for sun.gif

As a challenge, even with lots of help from others, I can’t quite figure out why my first song “Here Comes The Sun” isn’t playing properly. The code used to play almost all the notes, as in the video below. But with new code recommended to me, it doesn’t seem to recognize the button at all!




Leave a Reply

Your email address will not be published. Required fields are marked *