I am using a Nano to measure 0 to 5 volts on analog pins 0 to 7.
with only 1 input (A0) connected the program worked as intended, and the input was correctly measured.
After upscaling to use all 8 inputs (the diagram shows only A0 connected, but A1 to A7 are wired in the same way), the nano used so much power that the external voltage regulator shut down.
The code is below, please note that the code is for all 8 analog inputs, not just A0
#include <Wire.h>
#include <LiquidCrystal.h>
int sensorPin1 = A0; //AnalogIn 1
int sensorpin2 = A1; //AnalogIn 2
int sensorpin3 = A2; //AnalogIn 3
int sensorpin4 = A3; //AnalogIn 4
int sensorPin5 = A4; //AnalogIn 5
int sensorpin6 = A5; //AnalogIn 6
int sensorpin7 = A6; //AnalogIn 7
int sensorpin8 = A7; //AnalogIn 8
int sensorvalue1 = 0; // variable to store the value coming from AnalogIn 1
int sensorvalue2 = 0; // variable to store the value coming from AnalogIn 2
int sensorvalue3 = 0; // variable to store the value coming from AnalogIn 3
int sensorvalue4 = 0; // Variable to store the value coming from AnalogIn 4
int sensorvalue5 = 0; // variable to store the value coming from AnalogIn 5
int sensorvalue6 = 0; // variable to store the value coming from AnalogIn 6
int sensorvalue7 = 0; // variable to store the value coming from AnalogIn 7
int sensorvalue8 = 0; // Variable to store the value coming from AnalogIn 8
int outputvalue1 = 0; // variable to store the value coming from mapping1
int outputvalue2 = 0; // variable to store the value coming from mapping2
int outputvalue3 = 0; // variable to store the value coming from mapping3
int outputvalue4 = 0; // variable to store the value coming from mapping4
int outputvalue5 = 0; // variable to store the value coming from mapping5
int outputvalue6 = 0; // variable to store the value coming from mapping6
int outputvalue7 = 0; // variable to store the value coming from mapping7
int outputvalue8 = 0; // variable to store the value coming from mapping8
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; // to set digital out to drive LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
lcd.begin(20,4); // initialize the lcd
lcd.setCursor(0, 0); //specifying the "permanent" characters and placement
lcd.print("P1:");
lcd.setCursor(8, 0);
lcd.print("%");
lcd.setCursor(10, 0);
lcd.print("P2:");
lcd.setCursor(18, 0);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("P3:");
lcd.setCursor(8, 1);
lcd.print("%");
lcd.setCursor(10, 1);
lcd.print("P4:");
lcd.setCursor(18, 1);
lcd.print("%");
lcd.setCursor(0, 2);
lcd.print("P5:");
lcd.setCursor(8, 2);
lcd.print("%");
lcd.setCursor(10, 2);
lcd.print("P6:");
lcd.setCursor(18, 2);
lcd.print("%");
lcd.setCursor(0, 3);
lcd.print("P7:");
lcd.setCursor(8, 3);
lcd.print("%");
lcd.setCursor(10, 3);
lcd.print("P8:");
lcd.setCursor(18, 3);
lcd.print("%");
}
void loop()
{
sensorvalue1 = analogRead(sensorPin1); // read the value from sensor1
outputvalue1 = map(sensorvalue1, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue2 = analogRead(sensorpin2); // read the value from sensor2
outputvalue2 = map(sensorvalue2, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue3 = analogRead(sensorpin3); // read the value from sensor3
outputvalue3 = map(sensorvalue3, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue4 = analogRead(sensorpin4); // read the value from sensor4
outputvalue4 = map(sensorvalue4, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue5 = analogRead(sensorPin5); // read the value from sensor5
outputvalue5 = map(sensorvalue5, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue6 = analogRead(sensorpin6); // read the value from sensor6
outputvalue6 = map(sensorvalue6, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue7 = analogRead(sensorpin7); // read the value from sensor7
outputvalue7 = map(sensorvalue7, 0, 1023, -25, 100); // map it to the range of the analog out:
sensorvalue8 = analogRead(sensorpin8); // read the value from sensor8
outputvalue8 = map(sensorvalue8, 0, 1023, -25, 100); // map it to the range of the analog out:
lcd.setCursor(4, 0); // write the mapped value in specific positions
lcd.print(outputvalue1);
lcd.setCursor(14, 0);
lcd.print(outputvalue2);
lcd.setCursor(4, 1);
lcd.print(outputvalue3);
lcd.setCursor(14, 1);
lcd.print(outputvalue4);
lcd.setCursor(4, 2);
lcd.print(outputvalue5);
lcd.setCursor(14, 2);
lcd.print(outputvalue6);
lcd.setCursor(4, 3);
lcd.print(outputvalue7);
lcd.setCursor(14, 3);
lcd.print(outputvalue8);
delay(100);
}
I've checked for short circuits, and have found none, and the voltage drop across R2 is about 1 volt.
Please note that my field is as far removed from electronics and programming as can be, so everything here is copy/paste from other peoples projects
Thanks in advance
Rasmus
gaskammertester_simple.pdf (73.7 KB)