The first thing I did was make a code for the CPX. I did this using the website AdaFruit (makecode.com). The web site is very simple and easy to work with, enabling anyone to come up with cool codes. In this project, I focused on using the temperature sensor.

On the picture, you can see what my code looks like.

The way I constructed my code, is that it has two functions- when the switch is turned right and when it is turned left. The right side of the code is for when the switch is turned left. And when the switch is turned left, I programmed the CPX to show temperature. As you can see in the code, I assigned every 4 degrees Celsius (approximately) a different color, so I can see the CPX as a thermometer. Starting with purple at temperatures lower than -4˚, the colors go through blue, green, yellow, orange and red, coming to pink at temperatures higher than 28˚ and white (which is kind of impossible, as it is at temperatures higher than 100˚).

The left side of the code shows the functions of the CPX when the switch is turned right. For the right switch, I decided to program random colored lights just for fun, as an addition to the temperature showing. As seen in the image, when button A is pressed, a random number from 1-6 is chosen and that corresponds to one of five colors (I still need to add the sixth one). This way, after a short rainbow animation, I random color is chosen.

Another feature I added that is not shown in this image, is that when button B is pressed, the brightness increases by a lot (useful for bright days). To turn the brightness back down, all that is needed to do is to hold button B again for longer (about 5 seconds).