Controller accessories for video game consoles like
Nintendo’s “Power Glove” use flex-sensing technology. It
was the first video game controller attempting to mimic
hand movement on a screen in real time.
Circuit 2
Arduino Code:
9
Troubleshooting:
Servo Not Twisting
Even with colored wires it is still shockingly easy to plug a
servo in backwards. This might be the case.
Servo Not Moving as Expected
The sensor is only designed to work in one direction. Try
flexing it the other way (where the striped side faces
out on a convex curve).
Servo Doesn’t Move very Far
You need to modify the range of values in the call to the
map() function.
You should see the servo motor move in
accordance with how much you are
flexing the flex sensor. 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.
Code to Note:
Real World Application:
Open Arduino IDE
//
File > Examples > SIK Guide >
Circuit # 9
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.
Because the flex sensor / resistor combination won't give us a
full 0 to 5 volt range, we're using the map() function as a
handy way to reduce that range. Here we've told it to only
expect values from 600 to 900, rather than 0 to 1023.
servoposition = map(flexposition, 600, 900, 0, 180);
Because map() could still return numbers outside the "to"
range, we'll also use a function called constrain() that will
"clip" numbers into a range. If the number is outside the
range, it will make it the largest or smallest number. If it is
within the range, it will stay the same.
servoposition = constrain(servoposition, 0, 180);
map(value, fromLow, fromHigh, toLow, toHigh)
constrain(x, a, b)
Page 56
Содержание RedBoard
Страница 13: ...Page 11...