#include // LCD display const uint8_t RS_PIN = 10; const uint8_t EN_PIN = 7; const uint8_t BACKLIGHT_PIN = 6; // must be one of 3, 5, 6, 9, 10, or 11 for PWM const uint8_t D4_PIN = 5; const uint8_t D5_PIN = 4; const uint8_t D6_PIN = 3; const uint8_t D7_PIN = 2; // Connections: // LCD pin 1 to GND // LCD pin 2 to +5 // LCD pin 3 resistor to GND (1k seems reasonable) // LCD pin 4 (RS) to RS_PIN // LCD pin 5 (R/W) to GND // LCD pin 6 (E or EN) to EN_PIN // LCD pin 7 (D0) no connect // LCD pin 8 (D1) no connect // LCD pin 9 (D2) no connect // LCD pin 10 (D3) no connect // LCD pin 11 (D4) to D4_PIN // LCD pin 12 (D5) to D5_PIN // LCD pin 13 (D6) to D6_PIN // LCD pin 14 (D7) to D7_PIN // LCD pin 15 (A) to BACKLIGHT_PIN // LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2 LiquidCrystal lcd(RS_PIN, EN_PIN, D4_PIN, D5_PIN, D6_PIN, D7_PIN); void setup() { pinMode(BACKLIGHT_PIN, OUTPUT); analogWrite(BACKLIGHT_PIN, 40); // PWM the backlight lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc. lcd.clear(); // start with a blank screen lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row) lcd.print("Paul MacDougal"); // change this text to whatever you like. keep it clean. lcd.setCursor(0,1); // set cursor to column 0, row 1 lcd.print("GCBM v1.0"); // Start up the Serial port Serial.begin(9600); while (!Serial); Serial.println(F("Initialized GCBM v1.0")); } void loop() { uint16_t b1 = analogRead(A0); float v1 = b1 * 0.011977873; // 5.06/1023*(4700+3300)/3300.0 uint16_t b2 = analogRead(A1); float v2 = b2 * 0.020103072; // 5.06/1023*(10000+3300)/3300.0 uint16_t b3 = analogRead(A2); float v3 = b3 * 0.035620217; // 5.06/1023*(20000+3300)/3300.0 uint16_t b4 = analogRead(A3); float v4 = b4 * 0.046774392; // 5.06/1023*(27400+3300)/3300.0 uint16_t b5 = analogRead(A4); float v5 = b5 * 0.05483698; // 5.06/1023*(33000+3300)/3300.0 uint16_t b6 = analogRead(A5); float v6 = b6 * 0.076933002; // 5.06/1023*(47500+3300)/3300.0 lcd.clear(); lcd.setCursor(0,1); lcd.print(v1); lcd.setCursor(5,1); lcd.print(v2-v1); lcd.setCursor(10,1); lcd.print(v3-v2); lcd.setCursor(0,0); lcd.print(v4-v3); lcd.setCursor(5,0); lcd.print(v5-v4); lcd.setCursor(10,0); lcd.print(v6-v5); Serial.print(b1); Serial.print(" "); Serial.print(b2); Serial.print(" "); Serial.print(b3); Serial.print(" "); Serial.print(b4); Serial.print(" "); Serial.print(b5); Serial.print(" "); Serial.print(b6); Serial.println(" "); Serial.print(v1); Serial.print(" "); Serial.print(v2); Serial.print(" "); Serial.print(v3); Serial.print(" "); Serial.print(v4); Serial.print(" "); Serial.print(v5); Serial.print(" "); Serial.print(v6); Serial.println(" "); delay(1000); } /* ------------------------------------------------------------------------------- */