- Sound and Light with the Circuit Playground Express
- Fabric Potentiometer
- Capacitive Touch and Animations
- Coding an RGB LED with an Arduino UNO
Journal Entry #1: Sound and Light with the CPX
For my first journal entry, I wanted to attempt a part of the product I designed for the speculative wearable assignment. For the speculative wearable, I had designed a headband that lights up and changes colour based on the sounds around the wearer, as we have access to make code and our playground express’ I wanted to try and attempt to program my CPX to do the same. To begin, I began researching the capabilities of the CPX and what is in the microcontroller. Upon researching further I found a video on how to program the playground express to react with the sound around it. The code that I created by following this video was fairly simple but within the video, I also learned how to change the brightness of the lights using the switch on the board as well as connect my board to MakeCode itself so I could view the graphs based on the data from my playground circuit and not from the website simulation.
Below are my sound graphs for the sound level detected when faced with levels of 100 and 150, with the same music each time. I used the same music and volume level to understand how sensitive the circuit’s microphone really is to the sound around it. I immediately noticed that when using the level of 100 the lights were all lit up without any music playing yet and that the lights didn’t all light up with the sensitivity of 150 and the music playing directly beside the CPX.
I further decided to test the sensitivity of the CPX by placing the source of the sound at 2 more points of distance (within the same room) to see how the lights would be affected by the sound.
|Sound Level: 100
||Sound Level: 150
Moving the playground circuit at varying locations from the music didn’t change the number of lights blinking at certain points but it did affect the data in the chart. Different locations affected the varying levels of sound at the different time sources of the playground express. After creating the code, I played around with the sensitivity of the microphone to see which one would work best for the headband idea I had for the speculative wearable assignment. After playing around with the sensitivity level I decided the default level should be 125 just for areas in relatively low amounts of sound.
After completing this, I managed to program the playground express to light up with the sound I played around with the different light colours for different levels of sound.
This is the code I came up with:
I used conditional statements on the sound and the light patterns of the circuit playground express to create different patterns within the LEDs on the board. In doing this we won’t be able to see the sound “level” on the board as the lights don’t gradually move up according to the sound. Instead, the lights will all light up to a colour that signifies which sound level it is in.
Level of Sound
My first code when attempting to change the colour based on the level of sound around the circuit board only changed with three different levels so I tried another method that changes the colour to the actual sound level as the code of the colour, with the first attempt (shown above) it only changed the colour of the CPX to a navy blue even though the codes numbers varied. So trying a different method I instead set the hue value to the sound level and was able to change the colour of the lights to the value of the sound detected.
Overall this exploration was one I really enjoyed and can see myself doing stuff with in the future. I enjoy playing around with the CPX and learning the different things I can do with it. Learning what I can do with all the light settings on the CPX is something I will continue to explore in my own time. Managing to create a part of a product that I came up with for the speculative wearable assignment is something I am proud of because when coming up with my product for the assignment I assumed that an actual prototype version would be much harder to create but with the code that I learned during this exploration, I found that programming the actual lights isn’t as hard as I originally thought.
Ada, Lady. “Introducing Circuit Playground.” Adafruit Learning System, learn.adafruit.com/introducing-circuit-playground?view=all.
Core Electronics. “Sound Reactive Lights Project with Circuit Playground & MakeCode.” Youtube, 5 May 2018, www.youtube.com/watch?v=cNxQ9dT0kqY .
Journal Entry #2: Fabric Potentiometer
For my second exploration journal, I have tried to create the Fabric Potentiometer which was shown in the week 6 module. The idea of a “dial” that could change the amount of resistance going through the circuit is something that I want to explore. Using the design by KobaKant I wanted to create a volume bar so that on one side of the potentiometer the volume would be really low and on the other would be louder. I wanted to use volume instead of the tutorials use for the potentiometer to be a time sensor. I want to test the potential uses for this fabric “dial”. The original link from the presentation does link to an Instructables page but following that link brought me to a dead end as the instructable couldn’t be found. After searching in several places I was able to find an instructable that showed the uses of the time sensor bracelet and how to create one for the Arduino so I decided to apply some of the steps when creating my bracelet for the CPX. For the purposes of my experiment, I decided not to create a bracelet but just the volume sensor that I could connect to the CPX with alligator clips.
My process of drawing and assembling the circuit:
After assembling the circuit I went on to make the code. Taking the code for the pressure sensor workshop I added volume elements to each if statement to test if the volume would change at different locations on the potentiometer. This method did not end up working so I then attempted to change the volume equal to a variable that changed according to where the connection was placed.
First attempt (did not work): circuitplayground-AnalogScaleForVolume.uf2
Second Attempt (also did not work): circuitplayground-AnalogScaleForVolume2 (3).uf2
After changing the code multiple times I realized that I forgot to add a pull-up resistor to the velostat circle, once I added it I tried all the codes I had made so far and none of them were working as I wanted.
As I originally wanted to control the volume of the CPX’s programmable sounds with this potentiometer the sounds started to give me a headache after listening to them for a while so I decided to change what the potentiometer controls to the LEDs on the circuit playground express. To do so, I researched and found an article on the adafruit website about some basic codes that can be used to chang the lights on the CPX to the value of the potentiometer. Using this code my potentiometer is able to adjust the amount of lights according to where the extra piece of conductive fabric is. The lights are not always accurate to the position of the wiper on the potentiometer but it does adjust fairly well to the location of the wiper.
Images of final potentiometer:
Barela, Anne. “Make It Change: Potentiometers.” Adafruit Learning System, 18 Sept. 2018, learn.adafruit.com/make-it-change-potentiometers/makecode.
HOW TO GET WHAT YOU WANT, www.kobakant.at/DIY/?p=543%C2%A0%C2%A0.
Plusea. “Time Sensing Bracelet.” Instructables , 26 Mar. 2009, www.instructables.com/Time-Sensing-Bracelet/ .
Journal Entry #3: Capacitive Touch and Animations
Since the beginning of this semester, I have been wanting to try to create different light animations on the Circuit playground express. This week I attempted to do so by also using capacitive touch to trigger the two different animations I am planning on creating.
To begin with, this project I determined which pins I would use as the touch sensors, I decided to go with A2 and A6 since they are completely opposite one another. As the pins are far away from each other I won’t need to extend the sensor beyond the pin on the board.
The animations that I wanted to try and create are essentially one of the leaves turning to red and orange and another of apples falling from a tree. With these two concepts for the animations, I went into MakeCode to begin. I created an if statement and used functions to organize the lights and patterns, this way the code wouldn’t be super long and unorganized.
As the block to set all colours kept overriding the other colours I decided to declare each and every light separately even if the colour is on every pixel, this is because I wanted to see the animation as I was coding the lights. After completing the code, I would change this back to using the single block as declaring each and every light for the same colour causes them to turn on separately.
Playing around with the code took about an hour, as I started getting really picky over the formation of how the leaves turned red and orange as I didn’t want them to turn all one after another. The final version of my code changes some leaves to red before all the green leaves have left. I attempted to add a fade when the colours change but was unable to figure out the block to do so. As we only learned how to fade an external LED with the CPX in class, I tried to find a way to do a crossfade of the CPX’s internal LEDs but was unable to find a method that worked. As a result, I picked a softer change of colours that seems more natural from yellow to orange. The softer orange ended up looking very yellow, so I changed it to the standard code for orange.
Final Animation Code: circuitplayground-Capacitive-Touch-Exploration-Journal (2).uf2
Video of animations:https://youtu.be/nq7qMGykt_4
Journal Entry #4: Coding an RGB LED with an Arduino UNO
For my last journal entry, I wanted to figure out to use these 4 pin LEDs that I got in a box of LEDs from my local electronics store. Once, I figure out the differences and how to code each light I want to try coding some of the LEDs myself, with my Arduino UNO.
In the box, I bought I got two types of LEDs with 4 legs, and from what I understand I should be able to program which colour I want the LED to light up, so for this exploration journal I am going to research codes and ways I can use these LEDs and attempt to use the techniques with either my CPX or Arduino Uno. I started my exploration by trying to find the difference between the Intelligent control RGB Light is and other LEDs are, as they both look the same.
Upon researching the two LED types I couldn’t find any noticeable difference between how they will act when coded. So I decided to continue researching potential circuit setups for just the common LEDs. Most of the circuit diagrams I came upon had multiple potentiometers which I currently don’t have access to.
Then I started to look into different ways the code is made so I could find one in which we code the colours before sending the information to the Arduino and stumbled upon this circuit diagram and decided to attempt to try this set up for my common anode LED first.
The tutorial I followed used 2.2K ohm resistors, since I don’t have the same value resistor, I created them with two 1K resistors and a 220-ohm resistor on each pin that required resistors.
This is my circuit with the RGB common anode LED:
After I created my circuit I started to code the LED using the code provided on the same page as the fritzing diagram.
After copying the code to test the LED, I realized that the code would never work with the Arduino as it needed specific files within the library of the owner which I could not access to try and understand what it does. So I began researching another method to control the RGB values of the LED. Around this time, I started to wonder if I could use photosensors to control the value of each light, so I started researching the different ways to connect the photosensors to the LED to try this theory I had.
My photoresistor circuit (not including the 5V wire):
In the end, I couldn’t find anybody who had previously tried this so I decided to use codes that used potentiometers to adjust the colour led, using this code I would substitute the potentiometer for the photosensor which should essentially do the same thing as it is a type of sensor. The code that I used as a base is from this link: https://randomnerdtutorials.com/electronics-basics-how-do-rgb-leds-work/
The schematic diagram is also very similar to the setup I created which should help with coding my light.
Not only did the link provide the code, but it explained it easily which made it easier to understand what each part of the code does. I also stumbled upon a website that explained that the code for potentiometers and for photoresistors almost always is the exact same. You can check that link right here. (Links to an external site.)
This is the version of the code I used:
With this version I was able to change the colour of the LED to the photosensor that was in darkness, I was also able to combine the colours to create purple, yellow and white when there is little to no light on all the sensors. Video Link! (the red, green and blue led’s in the background are intended to stay off, they are just there as an indicator of which photosensor controls a specific colour.)