Hey, So I've made the midi glove, and im pretty sure all my connections are solid.
When i go to upload the code, im getting error messsages in arduino telling me that parts of the code are not declared in this scope.
For example, 'thumb' not declared in this scope
its happening for multiple fingers, as well as 'usbmidi' not declared in this scope.
What should I do ?
Midi Glove Arduino Code
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Midi Glove Arduino Code
Post your code here and make sure you have all the libraries needed and installed in the correct locations. Also post the output of the errors.
- handle1012
- Posts: 3
- Joined: Tue Apr 05, 2016 12:15 am
Re: Midi Glove Arduino Code
/*
Piezo Keyboard glove
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried & Becky Stern for Adafruit Industries.
BSD license, all text above must be included in any redistribution
*/
const int indexFinger = A9; // the piezo is connected to analog pin 9 (aka D9)
const int middleFinger = A7; // the piezo is connected to analog pin 7 (aka D6)
const int thumb = A10; // the piezo is connected to analog pin 10 (aka D10)
const int pinkyFinger = A11; // the piezo is connected to analog pin 11 (aka D12)
const int pins[] = {thumb, indexFinger, middleFinger, pinkyFinger};
char Keys[] = {'z','x','c','v'};
boolean currentPressed[] = {false, false, false, false};
const int threshold = 40; // threshold value to decide when the detected sound is a knock or not
void setup()
{
//while (!Serial)
Serial.begin(115200);
Serial.println("start");
Keyboard.begin();
}
void loop()
{
for (int i=0;i<4;i++) {
delay(1);
long total1 = 0;
long start = millis();
long total = analogRead(pins);
// check if we are sensing that a finger is touching
// and that it wasnt already pressed
if ((total > threshold) && (! currentPressed)) {
Serial.print("Key pressed #"); Serial.print(i);
Serial.print(" ("); Serial.print(Keys); Serial.println(")");
currentPressed = true;
Keyboard.press(Keys);
}
else if ((total <= threshold) && (currentPressed)) {
// key was released (no touch, and it was pressed before)
Serial.print("Key released #"); Serial.print(i);
Serial.print(" ("); Serial.print(Keys); Serial.println(")");
currentPressed = false;
Keyboard.release(Keys);
}
delay(5);
}
}
Thats the code that instruction manual gave me, and here is the error message.
Arduino: 1.6.7 (Windows 10), TD: 1.27, Board: "Arduino/Genuino Uno"
sketch_apr05a:12: error: 'A9' was not declared in this scope
const int indexFinger = A9; // the piezo is connected to analog pin 9 (aka D9)
^
sketch_apr05a:14: error: 'A10' was not declared in this scope
const int thumb = A10; // the piezo is connected to analog pin 10 (aka D10)
^
sketch_apr05a:15: error: 'A11' was not declared in this scope
const int pinkyFinger = A11; // the piezo is connected to analog pin 11 (aka D12)
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void setup()':
sketch_apr05a:30: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void loop()':
sketch_apr05a:49: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(Keys);
^
sketch_apr05a:57: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(Keys[i]);
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void setup()':
sketch_apr05a:62: error: redefinition of 'void setup()'
}void setup() {
^
sketch_apr05a:25: error: 'void setup()' previously defined here
void setup()
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void loop()':
sketch_apr05a:67: error: redefinition of 'void loop()'
void loop() {
^
sketch_apr05a:34: error: 'void loop()' previously defined here
void loop()
^
exit status 1
'A9' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Also, given their instructions its very unclear as to what I need to have downloaded and installed in terms of libraries.
I'm not complaining, because I'm pretty sure I did it correctly, but I cant be sure.
Piezo Keyboard glove
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried & Becky Stern for Adafruit Industries.
BSD license, all text above must be included in any redistribution
*/
const int indexFinger = A9; // the piezo is connected to analog pin 9 (aka D9)
const int middleFinger = A7; // the piezo is connected to analog pin 7 (aka D6)
const int thumb = A10; // the piezo is connected to analog pin 10 (aka D10)
const int pinkyFinger = A11; // the piezo is connected to analog pin 11 (aka D12)
const int pins[] = {thumb, indexFinger, middleFinger, pinkyFinger};
char Keys[] = {'z','x','c','v'};
boolean currentPressed[] = {false, false, false, false};
const int threshold = 40; // threshold value to decide when the detected sound is a knock or not
void setup()
{
//while (!Serial)
Serial.begin(115200);
Serial.println("start");
Keyboard.begin();
}
void loop()
{
for (int i=0;i<4;i++) {
delay(1);
long total1 = 0;
long start = millis();
long total = analogRead(pins);
// check if we are sensing that a finger is touching
// and that it wasnt already pressed
if ((total > threshold) && (! currentPressed)) {
Serial.print("Key pressed #"); Serial.print(i);
Serial.print(" ("); Serial.print(Keys); Serial.println(")");
currentPressed = true;
Keyboard.press(Keys);
}
else if ((total <= threshold) && (currentPressed)) {
// key was released (no touch, and it was pressed before)
Serial.print("Key released #"); Serial.print(i);
Serial.print(" ("); Serial.print(Keys); Serial.println(")");
currentPressed = false;
Keyboard.release(Keys);
}
delay(5);
}
}
Thats the code that instruction manual gave me, and here is the error message.
Arduino: 1.6.7 (Windows 10), TD: 1.27, Board: "Arduino/Genuino Uno"
sketch_apr05a:12: error: 'A9' was not declared in this scope
const int indexFinger = A9; // the piezo is connected to analog pin 9 (aka D9)
^
sketch_apr05a:14: error: 'A10' was not declared in this scope
const int thumb = A10; // the piezo is connected to analog pin 10 (aka D10)
^
sketch_apr05a:15: error: 'A11' was not declared in this scope
const int pinkyFinger = A11; // the piezo is connected to analog pin 11 (aka D12)
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void setup()':
sketch_apr05a:30: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.begin();
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void loop()':
sketch_apr05a:49: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.press(Keys);
^
sketch_apr05a:57: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
Keyboard.release(Keys[i]);
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void setup()':
sketch_apr05a:62: error: redefinition of 'void setup()'
}void setup() {
^
sketch_apr05a:25: error: 'void setup()' previously defined here
void setup()
^
C:\Users\Steve\BANNED\Documents\Arduino\sketch_apr05a\sketch_apr05a.ino: In function 'void loop()':
sketch_apr05a:67: error: redefinition of 'void loop()'
void loop() {
^
sketch_apr05a:34: error: 'void loop()' previously defined here
void loop()
^
exit status 1
'A9' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Also, given their instructions its very unclear as to what I need to have downloaded and installed in terms of libraries.
I'm not complaining, because I'm pretty sure I did it correctly, but I cant be sure.
- handle1012
- Posts: 3
- Joined: Tue Apr 05, 2016 12:15 am
Re: Midi Glove Arduino Code
That isnt the initial error message I was talking about. Ugh, I'm all messed up here!
- adafruit2
- Posts: 22194
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Midi Glove Arduino Code
you have to use the flora in teeonardu mode
https://learn.adafruit.com/atmega32u4-b ... eensyduino
but use Flora teensy as the board type
https://learn.adafruit.com/atmega32u4-b ... eensyduino
but use Flora teensy as the board type
Please be positive and constructive with your questions and comments.