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
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.
Most traditional volume knobs employ a potentiometer.
Circuit 2
Arduino Code:
2
Troubleshooting:
Sporadically Working
This is most likely due to a slightly dodgy connection
with the potentiometer's pins. This can usually be
conquered by holding the potentiometer down.
Not Working
Make sure you haven’t accidentally connected the
wiper, the resistive element in the potentiometer, to
digital pin 0 rather than analog pin 0. (the row of pins
beneath the power pins).
LED Not Lighting Up?
LEDs will only work in one direction. Try taking it out and
twisting it 180 degrees (no need to worry, installing it
backward does no permanent harm).
You should see the LED blink faster
or slower in accordance with your
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.
A “variable” is a stored value you’ve given a name to. You must introduce,
or "declare" variables before you use them; here we're declaring a variable
called sensorValue, of type "int" (integer). Don't forget that variable names
are case-sensitive!
int sensorValue;
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 2
What you Should See:
The Arduino is very very fast, capable of running thousands of lines of code
each second. To slow it down so that we can see what it's doing, we'll often
insert delays into the code. delay() counts in milliseconds; there are 1000 ms
in one second.
delay(sensorValue);
We use the analogRead() function to read the value on an analog
pin. analogRead() takes one parameter, the analog pin you want
to use ("sensorPin"), and returns a number ("sensorValue")
between 0 (0 volts) and 1023 (5 volts).
sensorValue = analogRead(sensorPin);
Page 28
Содержание RedBoard
Страница 13: ...Page 11...