Hello everyone, I'm new to the forum and have started my first project and unfortunately I'm having problems right away. I hope you can help me a little bit.
The problem is that I want to log different analog inputs. In the first step, the output to the serial Monitor is enough for me. I have soldered the sensors (FSR sensors) correctly to the analog inputs of my Nano 33 Sense Rev 2 and measured them, so there is no wiring problem, but when I run the program shown below, I only get the values for A0. I must have defined something wrong or something else. When I test the sensors individually, using another program that was the template, for only one sensor (https://arduinogetstarted.com/tutorials/arduino-force-sensor?utm_content=cmp-true#google_vignette), it works with all inputs. I must have done something wrong when rewriting the code for multiple inputs.
Thanks for your help
const byte inputs[] = {A0,A1,A2,A3,A6};
void setup() {
Serial.begin(9600);
while (!Serial);
}
void loop()
{
for (int pin = 0; pin < 2; pin++)
{
int dummy = analogRead(inputs[A0]);
int value = analogRead(inputs[A0]);
Serial.print("Force sensor 1 reading = ");
Serial.print(value); // print the raw analog reading
if (value < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (value < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (value < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (value < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(100);
}
for (int pin = 0; pin < 2; pin++)
{
int dummy = analogRead(inputs[A1]);
int value = analogRead(inputs[A1]);
Serial.print("Force sensor 2 reading = ");
Serial.print(value); // print the raw analog reading
if (value < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (value < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (value < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (value < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(100);
}
for (int pin = 0; pin < 2; pin++)
{
int dummy = analogRead(inputs[A2]);
int value = analogRead(inputs[A2]);
Serial.print("Force sensor 3 reading = ");
Serial.print(value); // print the raw analog reading
if (value < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (value < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (value < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (value < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(100);
}
for (int pin = 0; pin < 2; pin++)
{
int dummy = analogRead(inputs[A3]);
int value = analogRead(inputs[A3]);
Serial.print("Force sensor 4 reading = ");
Serial.print(value); // print the raw analog reading
if (value < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (value < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (value < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (value < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(100);
}
for (int pin = 0; pin < 2; pin++)
{
int dummy = analogRead(inputs[A6]);
int value = analogRead(inputs[A6]);
Serial.print("Force sensor 5 reading = ");
Serial.print(value); // print the raw analog reading
if (value < 10) // from 0 to 9
Serial.println(" -> no pressure");
else if (value < 200) // from 10 to 199
Serial.println(" -> light touch");
else if (value < 500) // from 200 to 499
Serial.println(" -> light squeeze");
else if (value < 800) // from 500 to 799
Serial.println(" -> medium squeeze");
else // from 800 to 1023
Serial.println(" -> big squeeze");
delay(100);
}
}