This week's assigment required us to use an RGB LED to create a lamp that would go through different colors, keep the color it was last given, dim its brightness and be turned on and off.
My idea was to create a lamp that within itself could embody the controls that will make it work. SInce time constrains represent also project concerns I had to make peace with adapting my original idea to the controls and materials I had available.
When it came to building a circuit this was no problem as it is quite straight forward the way an LED, a pot and a proximity sensor get wired. In order to make sure I was doing things right I went back to this project ignite I had played with before
My huge struggle during this project was with the code. The on and off swich I applyied it to the current, so I just had to play around and understand how the Pot and the Proximity Sensor would modify the colors and the brightness of the LED.
Starting off with the color issue I applied for loops that would help me see how the colors changed in an automatic way so that I could break the loop logic and add a control in it. The problem that I dragged form this starting point and throughout was that I sticked with RGB, never moving to HSV. And it mainly had to do with the fact that I started off with this code I found and stuck to it.
So after trying different solutions I ended up assigning a color combination transition to every sixth of the pot turn. After realizing I just needed to remove the delay I was able to get the needed effect.
Then I moved into incorporating my proximity/light sensor (which's library took me a really long time to find -fritzing part-)and I had a hard time figuring out why it would work, even tryied out millis as a way of checking for the stage change and it still was not reading it. And then, spotted the line that I was not writting in my final code:
sensorValue = faboProximity.readProx();
Once with a working circuit I moved into fabrication. But appart from the HSV optimization I was left with the curiosity of trying Swich case instead of all the ifs and ANDs I used. Would that make my code more efficient?