In need of code for using a Dimmer knob with an i2C LCD Display

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());
        
        
      }
    }
  }

}
  }

http://forum.arduino.cc/index.php?topic=153916.0

Does this help? While there is no code, it walks through what you'll need to do.

I did do a search and found that thread but my problem is that I am too new to this.. I dont know what half the terms they are using means..

i.e ppm output, PWM control, Pot, h/w, NPN Transistor..

I think that the dimmer I have is a Resistor switch/knob but not sure.. I found it in a box of junk. Like that thread said.. "The blind leading the blind"...

The USRM dude mentioned he hooked a PPM output to the upper pin of the jumper pins and it works.. But Im not sure what that means.. I tried hooking the output of my dimmer/knob to that pin and it almost works.. All the way left no back light and almost see the text in light at an angle.. Turn the knob to the right and about 20 degrees to the end the back light and text light up a level or two then all the way on for the last 10 degrees or so...

Maybe first I should find out what type of knob I'm using.. ::slight_smile:

Again, sorry for my ignorance! There is just so much to learn...

I'm fairly new at this too so no worries.
What is the 'upper pin of the jumper pin'? What do you mean by this.

It sounds like you're getting there though. What's your current issue?

Hello Owl! Well the is that the knob only turns it on and off.. No in between using the LED jumper Pin..

What I meant by the upper pin of the jumper pin is the pin labeled LED with the jumper on it in the picture below.. On the left of the I2C backpack...

I am basically in need of code that will make the back light dim with the Analog readings I get from the knob...

Thanks for any advice in advance... :wink: