I had a dimmer laying around and thought it would be easily be able to hook this up to the jumpers on the back pack of the display but that doesnt work as I expected...
The dimmer has 3 prongs, With Ground on the left, + 5 V on the right and the center pin going to assinged pin A3 I get readings.. When I turn the knob all the way to the left I get readings of 0 and turned to the right I get a high of 1022 in the serial monitor with the code below..
void setup() {
Serial.begin(9600);
}
void loop() {
int dimmerValue = analogRead(A3);
Serial.print("Display = ");
Serial.println(dimmerValue);
delay(250);
}
Does anyone know quick code that will make those analog numbers Dim my 20x4 i2c Dispaly?
Help would be greatly appreciated!
Here is a pick of the back of the display and dimmer.
Here is all the code I have compiled so far..
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
Serial.begin(9600);
Serial.println("DHT11");
dht.begin();
lcd.begin(20,4);
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: Lines and Characters start at 0
lcd.setCursor(3,0); //Start at character 3 on line 0
lcd.print("Mini Dyno 2000");
delay(1000);
lcd.setCursor(5,1);
lcd.print("Powered by");
delay(1000);
lcd.setCursor(5,2);
lcd.print("SimpleDyno");
delay(2500);
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = (t* 9 +2)/5+32; // The +2 takes care of the better rounding
delay(1000);
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(f);
Serial.println(" *F");
lcd.setCursor(3,0);
lcd.print("Mini Dyno 2000");
lcd.setCursor(3,1);
lcd.print("Humidity:");
lcd.print(h);
lcd.print("% ");
lcd.setCursor(3,2);
lcd.print("Temp: ");
lcd.print(f);
lcd.print(" *F ");
lcd.setCursor(0,3);
lcd.print("Altitude: "); // waiting on sensor
lcd.print("605 Feet"); // Burbank Altutude
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}
}
}