Hey everyone !
I'm building a project using Teensy 2, and everything works perfectly.
Except for one thing : I'm using the 12 Analog In pins to measure voltages coming from potentiometers. It works fine with every pin, but the PD6 one .. which is connected to the internal LED.
When changing the voltage on that pin, the luminosity of the LED changes (which is fine) the problem is I canot get the voltage down to 0 ..
I'm then using the AnalogRead function and converting it into a MIDI information. But the MIDI message will go down to 2 and not 0.
(For other Analog Inputs I can do 0-127, but this one only 2-127).
I though there might be a way to deactivate the LED to solve the problem, but haven't been able to figure it out.
Any information would be useful
Many thanks ! Max.
I don't think it is because of a mistake into my code, but just in case :
#include <Bounce.h>
// define how many pots are active up to number of available analog inputs
#define analogInputs 12
// make arrays for input values and lagged input values
int inputAnalog[analogInputs];
int iAlag[analogInputs];
// make array of cc values
int ccValue[analogInputs];
// index variable for loop
int i;
void setup() {
// MIDI rate
Serial.begin(31250);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
}
void loop() {
// loop trough active inputs for knobs
for (i=0;i<analogInputs;i++){
// read current value at i-th input
inputAnalog = analogRead(i);
// if magnitude of difference is 8 or more...
if (abs(inputAnalog - iAlag) > 7){
// calc the CC value based on the raw value
ccValue = inputAnalog/8;
// send the MIDI
usbMIDI.sendControlChange(i+20, ccValue, 14);
// set raw reading to lagged array for next comparison
iAlag = inputAnalog;
}
delay(1); // limits MIDI messages to reasonable number
Serial.println(inputAnalog[11]);
}
}
I'm building a project using Teensy 2, and everything works perfectly.
Except for one thing : I'm using the 12 Analog In pins to measure voltages coming from potentiometers. It works fine with every pin, but the PD6 one .. which is connected to the internal LED.
When changing the voltage on that pin, the luminosity of the LED changes (which is fine) the problem is I canot get the voltage down to 0 ..
I'm then using the AnalogRead function and converting it into a MIDI information. But the MIDI message will go down to 2 and not 0.
(For other Analog Inputs I can do 0-127, but this one only 2-127).
I though there might be a way to deactivate the LED to solve the problem, but haven't been able to figure it out.
Any information would be useful
Many thanks ! Max.
I don't think it is because of a mistake into my code, but just in case :
#include <Bounce.h>
// define how many pots are active up to number of available analog inputs
#define analogInputs 12
// make arrays for input values and lagged input values
int inputAnalog[analogInputs];
int iAlag[analogInputs];
// make array of cc values
int ccValue[analogInputs];
// index variable for loop
int i;
void setup() {
// MIDI rate
Serial.begin(31250);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
}
void loop() {
// loop trough active inputs for knobs
for (i=0;i<analogInputs;i++){
// read current value at i-th input
inputAnalog = analogRead(i);
// if magnitude of difference is 8 or more...
if (abs(inputAnalog - iAlag) > 7){
// calc the CC value based on the raw value
ccValue = inputAnalog/8;
// send the MIDI
usbMIDI.sendControlChange(i+20, ccValue, 14);
// set raw reading to lagged array for next comparison
iAlag = inputAnalog;
}
delay(1); // limits MIDI messages to reasonable number
Serial.println(inputAnalog[11]);
}
}