Description
As of this lab, we are beginning to use sensors as input devices. We add potentiometers as a means of simple interaction with the Arduino. We continue to build off the circuit of previous weeks, and in this case, continue to use three LEDs whose values are set by PWM pins on the Arduino, but add the capability to provide input through three potentiometers, connected to analog pins on the Arduino Uno.
The most time consuming aspect of adding the pots to the circuit was their preparation; cutting, trimming, and soldering the wires to the pot took a little while longer than connecting it to the circuit. However, once they are connected, the simple programs to adjust the brightness and blinking rate of the LEDs is fairly straightforward.
I toyed with various ideas for controlling the LEDs with the pots. I came up with two distinct ideas, though I only implemented the second. In the first, I thought this might be an interesting opportunity to map different color spaces to the three pots. For example, it's relatively trivial to assign each pot to one of the R, G, and B LEDs, essentially creating an RGB colorspace input device. I thought it might be a good opportunity to explore other color spaces like LAB, in which one pot would adjust the "Lightness" value, and the other two would adjust "A" and "B" values, which define the color-opponent dimensions in the color space. I decided against this, however, because it is a rather esoteric use of the pots and I thought only die-hard Photographers and Photoshoppers would appreciate the mapping.
Instead, I decided to make a game called "Pot Twist" out of the three pots. Each pot controls one LED, and twisting that pot will increase or decrease the brightness of the LED. In each level of the game, the LEDs begin completely dimmed, and the goal of each level is to cause all three LEDs to glow their brightest. In each subsequent level, however, additional requirements are set: one pot might only adjust its corresponding LED if another LED is already completely bright, for instance, or the pots might be reassigned to different LEDs.
The game includes 5 levels of approximately increasing difficulty. Due to limited time in the lab, I could not perform usability studies to guarantee that each level increases in difficulty for every player; it really depends on how the player approaches the game. I had a bit of difficulty with some aspects of the game due to the Arduino's limitations: calculating the LED's value based on the pot's offset, for instance, was mired with problems becasue taking the modulus of a negative number was unpredictable.
Try to see how quickly you can win the game!
Components Used
1- Arduino Uno
3- LEDs (red, green, blue)
3- 220 Ohm resistors
3- potentiometers
Code
The code is attached here, rather than pasted: Download Here.
- Login to post comments