The knobs found on many objects, like a radio for
instance, are using similar concepts to the one you just
completed for this circuit.
Circuit 2
Arduino Code:
10
Troubleshooting:
LED Remains Dark or Shows Incorrect Color
With the four pins of the LED so close together, it’s
sometimes easy to misplace one. Try double checking each
pin is where it should be.
Bizarre Results
The most likely cause of this is if you’re pressing the
potentiometer in more than one position. This is normal
and can actually be used to create some neat results.
You should see the RGB LED change
colors in accordance with how you
interact with the soft potentiometer.
If it isn't working, make sure you
have assembled the circuit correctly
and verified and uploaded the code to
your board, or see the
troubleshooting tips below.
These big, scary functions take a single
Value (RGBposition) and calculate the
three RGB values necessary to create a
rainbow of color. The functions create
three "peaks" for the red, green, and
blue values, which overlap to mix and
create new colors. See the code for more
information!
Even if you're not 100%
clear how it works, you can copy and
paste this (or any) function into your
own code and use it yourself. If you
want to know more about creating your
own functions - take a look at circuit
#11.
redValue = constrain(map(RGBposition, 0, 341, 255, 0), 0, 255)
+ constrain(map(RGBposition, 682, 1023, 0, 255), 0, 255);
greenValue = constrain(map(RGBposition, 0, 341, 0, 255), 0, 255)
- constrain(map(RGBposition, 341, 682, 0,255), 0, 255);
blueValue = constrain(map(RGBposition, 341, 682, 0, 255), 0, 255)
- constrain(map(RGBposition, 682, 1023, 0, 255), 0, 255);
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 10
What You Should See:
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
IOREF
RES
ET
RESET
7-15V
SCL
SDA
AREF
GND
13
12
~11
~10
~9
8
7
~6
~5
4
~3
2
1
0
TX
RX
13
3.3V
5V
GND
GND
VIN
A0
A1
A2
A3
A4
A5
POWER
ANALOG IN
DIGIT
AL (PWM~)
ON
ISP
TX
RX
LEARN. SHARE. HACK.
Page 60
Summary of Contents for RedBoard
Page 13: ...Page 11...