How to Use a Screen to Display CPU Temp (not thermistor)?

Belial88:
can you seriously not edit posts?

Yes but there may be a time limit.

Belial88:
Can this same mod be done with a TFT?

Not following you, what mod ? Are you referring to the type of LCD used ?

like is it possible to use a TFT to display whatever I want, from the computer. Like is it possible to do what we’ve done with the lcd, instead with a tft. Because I don’t see any ‘TFTSmartie’ program.

TFT refers to a type of LCD. So it depends on the TFT LCD you choose. Almost anything is possible w/enough $$$s.

http://en.wikipedia.org/wiki/Thin-film- … al_display

I mean something like this:

http://www.adafruit.com/images/medium/18tftbob_MED.jpg

you know, all those sub-100, tft’s all over the place you find LCD 20x4s and stuff. All I really see are like, load up your sd card and it’ll show images like those crappy photoframe things you see in people’s houses sometimes. i mean if i can hook this tft just as a display, that’s fine.

The new code seems to work well :slight_smile:

Belial88:
I mean something like this:

i mean if i can hook this tft just as a display, that’s fine.

Aaah, it would take much more than an Arduino to 'drive' it. Just too many pixels. Some custom software on the PC side would be needed if you're trying to be very 'graphical'. Now some come w/their own processor onboard and some form of serial data interface. I suppose an Arduino and Smartie could be used to put pretty character data on a pretty background w/such a display. A lot depends on the 'smartness' of the display. You could say they come in varying 'IQs', w/prices to match.

Belial88:
The new code seems to work well :slight_smile:

Good !

http://www.youtube.com/watch?v=D1EAKzHX … e=youtu.be

Servo operation, a little buggy due to weak connections

Color me surprised that the servo can move the door frame that quickly. I can see why the VarSpeedServo code is needed !

Well in that video you can see that like 95% of the metal on my side panel was taken off for my huge window. The acrylic should add more weight to it, i’ll add a video once i do it with the window on.

Is there an easy way for soldering all my 5v and grnd connections together instead of 10 wires cramming into 1 hole on the arduino? Technically the order doesnt matter right, so I could have like my grnd for my lcd going to the grnd to something like the servo which then goes to a switch which goes to the grnd, right?

Is there like… a pod or something I could use? I mapped out all my connections for the components, and its a bit complicated. To name the parts in my system:

  • 24 Pin Mobo connector (for 5vsb/grnd for battery power to UPS battery)

  • Powergen Battery (with an Out for 24pin, and In for the arduino)

  • Arduino Micro

  • Servo

  • 2 x Connections on Motherboard to voltmeter

  • Trim Pot

  • Momentary Switch (servo)

  • Switch (Put in the (+) of Arduino USB 5v to Powergen UPS Battery so to shut off for long term storage, neatly the powergen will shut off after about a minute of no use but the arduino is enough to trigger as action)

  • Motherboard Internal USB Header (where I hook up arduino’s usb data lines)

  • LCD

each thing pretty much has a shared grnd wire to the arduino, most have a 5v going to it, the lcd has like 3 grnds and 5vs on its own.

Oh, and while I want the servo and arduino to run off battery, I want the lcd to run off the computer (usb, 5v, whatever, just to turn off when pc is off).

I imagine this is simple, I just hook up the lcd power to something else. But what exactly, since the pins are so tied up on everything. Do I plug all 5v/GRND lines of the LCD to something else? I was thinking of having the +/grnd of the lcd go to the +/grnd on the mobo usb header, the same one who’s 2x data lines go to the arduino (whose own power lines, instead of going to mobo, go to the ups battery).

Or would it be simpler to make it go to just like my PSU’s 5v/grnd lines?

Basically, to run an lcd off different power from the arduino, do I put just pins 1 and 2 (vcc and grnd) on a different power plane, or do I put all lcd pins that go to 5v/grnd to different power plane (1, 2, as well as 5-rw, 15-lcd).

Belial88:
Is there an easy way for soldering all my 5v and grnd connections together instead of 10 wires cramming into 1 hole on the arduino?

You could use a terminal/barrier strip. They come in a variety of types and sizes and can be used w/bare wires or crimp-on lugs. "Jumpers" can be used to connect individual blocks together.

http://www.adafruit.com/adablog/wp-cont … -strip.jpg

http://www.slagcoin.com/joystick/pcb_wiring/block.jpg

http://mixguides.com/consoles/vintage_p … G2.WEB.jpg

I imagine this is simple, I just hook up the lcd power to something else. But what exactly, since the pins are so tied up on everything. Do I plug all 5v/GRND lines of the LCD to something else? I was thinking of having the +/grnd of the lcd go to the +/grnd on the mobo usb header, the same one who’s 2x data lines go to the arduino (whose own power lines, instead of going to mobo, go to the ups battery).

Or would it be simpler to make it go to just like my PSU’s 5v/grnd lines?

Hard for me to answer, whatever is easiest I suppose.

Basically, to run an lcd off different power from the arduino, do I put just pins 1 and 2 (vcc and grnd) on a different power plane, or do I put all lcd pins that go to 5v/grnd to different power plane (1, 2, as well as 5-rw, 15-lcd).

All you really need is a separate Vcc (5v?) for the LCD. Just make sure that somehow every items "ground" are all tied together.

Interesting, okay so I’ll get a barrier strip from radio shack and just have one side be grounds, one side be 5vs. All 5vs go to them, and grnds go to it.

I’m not sure I’m following your LCD Pinout for alternate Power explanation. The Arduino + Servo will run of a USB Cell Phone Battery Charger (which will act as a UPS, as it will be powered by the 5VSB line on the computer PSU, that way it’ll be charging even when PC is off, whereas 5v rail or usb will not.). The LCD, I want to turn off with the computer, not just for simplicity but also to prevent the battery drain it would precipitate.

So Pins 15 (backlight) is 5v, RW is Grnd, and then there’s VCC and GRND. Do I hook up VCC/GRND only to a separate battery, or do I need to hook up all the pins, such as Backlight 15 and RW, to that same separate power? Or do I just plug them into the arduino?

We could also maybe code the LCD to turn off when the PC is turned off, and the arduino would receive a signal if the pc turned off… but I’m thining that’s more complicated? ANd wouldn’t it mess with the Voltmeters and Servo power a bit, since the LCD is just amother component on the line, and the less we have on the line, the cleaner and more accurate everything is, like the reference voltage, so my voltmeters become more accurate, and my servo moves more consistently?

Thans.

Someone on reddit said this:

If you power down the LCD and ‘drive’ any one of the I/O there is a good chance you will fry the LCD, depending on the specific nature of the I/O of the LCD device. They may or may not have input protection and that input protection may or may not be able to tolerate sustained current. Driving the LCD I/O may prove to be a major drain on your battery.

If you can’t be certain, you will need to make sure this doesn’t happen by using a buffer or something.

Belial88:
Someone on reddit said this:

If you power down the LCD and ‘drive’ any one of the I/O there is a good chance you will fry the LCD, depending on the specific nature of the I/O of the LCD device. They may or may not have input protection and that input protection may or may not be able to tolerate sustained current. Driving the LCD I/O may prove to be a major drain on your battery.

If you can’t be certain, you will need to make sure this doesn’t happen by using a buffer or something.

I doubt you'd hurt the LCD controller. I guess it's possible you'd hurt the Arduino pins driving the unpowered LCD. It's probably no good for battery life (driving dead pins) so it would be wise to use a spare pin to sense the LCDs power (Vcc and backlight 5v) and when power is off, set all the pins to inputs. Now any write to those pins will, at most, switch the Arduino's internal pull-ups on/off. Even better would be to do that *and* skip any writing to the LCD. Then nothing can be hurt and power is conserved.

BTW be aware that the “top” and “bottom” terminals of the strip (pictured above) are tied (electrically) together. Each terminal pair can then be tied, or not, to it’s neighbor(s) via jumpers. Be sure you don’t accidentally tie 5v to ground.

How in the world would I have a spare pin to sense the LCD’s power?

Even better would be to do that and skip any writing to the LCD. Then nothing can be hurt and power is conserved.

I don’t understand what you mean here. I understood the first part, I think that makes sense because in the definitions I remember we defined pins being outputs. So I’m not sure how we change the set-up part because those definitions wouldn’t work anymore, but I imagine some sort of If>than statement being made in loop where if Sensor=On, than Pin Definitions =Output. Not sure if I could write that code.

I assume this sensor pin would be analogue, like from the voltmetering we did. And… just tack it on to the VCC line (or to the same alternate power as lcd, etc) and then just basically tie the alternate power ground to arduino ground. Some sort of… if voltage is less than 1, change inputs definitions.

i posted this on like 5 different forums, and you answered mee_n_mac. that’s just crazy.

Belial88:
I assume this sensor pin would be analogue, like from the voltmetering we did. And… just tack it on to the VCC line (or to the same alternate power as lcd, etc) and then just basically tie the alternate power ground to arduino ground. Some sort of… if voltage is less than 1, change inputs definitions.

The pin could be a digital or analog input, the coding would be a little different, but since you're all out of the former, analog it shall be. I'd do exactly what you said; sample the pin and if the voltage is > XYZ volts set a "flag" that the LCD power is on (LCDpwr = true), otherwise it's false. I'll have to relook at your code to find the proper place to stick the whole enable/disable business and to get the setup() correct. An idea might be to write a new function that uses the new "flag" and then call that function where appropriate. Perhaps the function might read the analog pin and skip setting any flag. I'll have to relook at your code to figure out which is best.

Perhaps later tonight … if I’m not out abusing my liver. :mrgreen:

So I guess it doesnt matter whether I hook up those other pins, Backlight (+) and RW(-) to either the arduino or the alternate power, if we’re telling the arduino to stop writing to lcd right?

Belial88:
So I guess it doesnt matter whether I hook up those other pins, Backlight (+) and RW(-) to either the arduino or the alternate power, if we’re telling the arduino to stop writing to lcd right?

Backlight (+) is the power to the backlight LEDs and should go with Vcc to the switched power supply. RW is a signal to the LCD that tells it to read or write. Since you're always writing to the LCD, it gets grounded (= logic 0). And since all grounds must get tied together (electrically), it doesn't matter where (physically).

OK, here’s a new sketch that looks for LCD power on the A3 pin and if it’s not there, resets the output pins to the “dead” LCD to be inputs. When power comes back, they revert back and the LCD is re-initialized. So add a wire from the LCD supply voltage (where ever you can grab it) and run it to the Arduino analog 3 pin. Then make sure everything works as before. If you can, then cycle the LCD power while leaving the Arduino on. Again see if everything works as it should after the power on-off-on cycle.

#include <VarSpeedServo.h>  //variable speed servo library
#include <LiquidCrystal.h>

//declare the constants to be used
#define LEDPIN 13             //pin attached to LED
#define servoPIN 9            //Servo control line
#define SWitchPIN 2           //input from N.O. momentary switch
#define redPIN 12             //PWM pin for red LED backlight
#define greenPIN 11           //PWM pin for green LED backlight
#define bluePIN 10            //PWM pin for blue LED backlight
#define rsPIN 8               //reset pin for LCD
#define enablePIN 3           //enable pin for LCD
#define d4PIN 4               //data pin4 for LCD
#define d5PIN 5               //data pin5 for LCD
#define d6PIN 6               //data pin6 for LCD
#define d7PIN 7               //data pin7 for LCD
// these constants won't change.  But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
const int ignoreMAX = 6;      //ignore this many characters
const unsigned long wait = 50;//wait time for ADC update after last Smartie cmd
#define posOpenCMD 1900       //Define Clockwise Servo position in usec
#define posCloseCMD 600       //Define CounterClockwise Servo position in usec
#define DBdelay 2000          //Min time needed btw any 2 button presses, in msec
#define fastSPD 100           //speed setting; 1 = slowest, 255 is fastest (???)
#define slowSPD 15            //Speed Servo/Door opens and closes (15 is good average)
#define DIV_1    1.0          //gain correction for A0 channel
#define DIV_2    1.0          //note it's 1.0, not 1, to get full floating point accuracy

#define V_REF    2.54         //use the measured Aref voltage

//declare the variables used
boolean updateFlag = false;          //flag to refresh ADC readings
boolean LCDpwr = false;              //flag to presense of power to LCD
volatile boolean doorOPEN = false;   //desired door state set to closed
byte rxbyte = 0;                     //rxbyte is the received byte from Smartie
byte temp = 0;
int ignoreCNT = 0;                   //count of characters to ignore
int row = 0;                         //index of last row position
int col = 0;                         //index of last col position
int rowA0 = 0;                       //index of A0 row position
int colA0 = 0;                       //index of A0 col position
int rowA1 = 0;                       //index of A1 row position
int colA1 = 0;                       //index of A1 col position
unsigned long MSGtime = 0;           //holds the time of the last cursor cmd
volatile unsigned long SWtime = 0;   //holds the time of the last valid switch push
float voltage1 = 0.0;                // calculated voltage for A0
float voltage2 = 0.0;                // calculated voltage for A1

LiquidCrystal lcd(rsPIN, enablePIN, d4PIN, d5PIN, d6PIN, d7PIN);
VarSpeedServo myServo; //create a servo object

void setup() {
  //set the pins to be ins or outs
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);            //turn LED off
  pinMode(servoPIN, OUTPUT);
  pinMode(SWitchPIN, INPUT_PULLUP);
  delay(1000);                          //wait for LCD power to stabilize
  checkLCD();                           //check for LCD power, initialize if it does

  attachInterrupt(1, SW_ISR, FALLING);

  Serial.begin(9600);

  analogReference(INTERNAL);              //use the internal 2.56v ADC reference

  //CMD the servo to close the door
  myServo.attach(servoPIN);               // Attach the servo
  myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position

  //put a hello world on the LCD if it has power
  if(LCDpwr){
    lcd.print("Line 1");
    lcd.setCursor(3, 1);
    lcd.print("Line 2");
    lcd.setCursor(8, 2);
    lcd.print("Line 3");
    lcd.setCursor(13, 3);
    lcd.print("Line 4");
    delay(2000);
  }
}


//the main loop is now just the hacked version of the Arduino Smartie code
void loop(){
  rxbyte = serial_getch(); //this calls the 'function' serial_getch(), stores result in rxbyte
  if (rxbyte == 254)     //Matrix uses 254 for commands, if rxbyte = 254 the the code below runs
  {
    ignoreCNT == 0;          //turn off character ignoring whenever a command is sent
    switch (serial_getch())  //calls serial_getch() to get the next byte from the PC
    {
    case 66: //former backlight on command
      break;
    case 70: //former backlight off command
      break;
    case 71:  //set cursor position
      MSGtime = millis();           //remember time that cursor cmd was sent
      updateFlag = true;            //set flag to update ADC readings
      row = 0;
      col = 0;
      temp = (serial_getch() - 1);  //get column byte
      switch (serial_getch())       //get row byte
      {
        //line 1 is already set up
      case 2:
        row = 1;
        temp += 0x40;
        break;
      case 3:
        row = 2;
        temp += 0x14;
        break;
      case 4:
        row = 3;
        temp += 0x54;
        break;
      default:
        break;
      }
      lcd.command(0b10000000 + temp);
      break;
    case 72:  //cursor home (reset display position)
      lcd.command(2);
      break;
    case 74:  //show underline cursor
      lcd.command(0b00001110);
      break;
    case 75:  //underline cursor off
    case 84:  //block cursor off
      lcd.command(0b00001100);
      break;
    case 76:  //move cursor left
      lcd.command(16);
      break;
    case 77:  //move cursor right
      lcd.command(20);
      break;
    case 78:  //define custom char
      lcd.command(64 + (serial_getch() * 8));  //get+set char address
      for (temp = 7; temp != 0; temp--)
      {
        lcd.print(serial_getch()); //get each pattern byte
      }
      break;
    case 83:  //show blinking block cursor
      lcd.command(0b00001111);
      break;
    case 86:  //GPO OFF
      //implement later
      break;
    case 87:  //GPO ON
      /*temp = serial_getch();
       if (temp == 1)
       {
       GPO1 = GPO_ON;
       }*/
      break;
    case 88:  //clear display, cursor home
      lcd.command(1);
      break;
    case 152: //set and remember (doesn't save value, though)
    case 153: //set backlight brightness
      //not implemented
      break;

      //these commands ignored (no parameters)
    case 35: //read serial number
    case 36: //read version number
    case 55: //read module type
    case 59: //exit flow-control mode
    case 65: //auto transmit keypresses
    case 96: //auto-repeat mode off (keypad)
    case 67: //auto line-wrap on
    case 68: //auto line-wrap off
    case 81: //auto scroll on
    case 82: //auto scroll off
    case 104: //init horiz bar graph
    case 109: //init med size digits
    case 115: //init narrow vert bar graph
    case 118: //init wide vert bar graph
      break;
    default:
      //all other commands ignored and parameter byte discarded
      temp = serial_getch();  //dump the command code
      break;
    }
    return;
  } //END OF COMMAND HANDLER

  //change accented char to plain, detect and change descenders
  //NB descenders only work on 5x10 displays. This lookup table works
  //  with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
  switch (rxbyte)
  {
    //chars that have direct equivalent in LCD charmap
    /* case 0x67: //g
     rxbyte = 0xE7;
     break;
     case 0x6A: //j
     rxbyte = 0xEA;
     break;
     case 0x70: //p
     rxbyte = 0xF0;
     break;
     case 0x71: //q
     rxbyte = 0xF1;
     break;
     case 0x79: //y
     rxbyte = 0xF9;
     break;
     */
  case 0x5B: //Formerly [, now does A0 ADC
    voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;           
    lcd.print(voltage1, 3);
    rxbyte = 0x76;           //will cause v to be displayed
    ignoreCNT = ignoreMAX;   //ignore characters replaced by ADC reading
    updateFlag = false;      //reset ADC update flag
    rowA0 = row;             //store row of A0 reading
    colA0 = col;             //store col of A0 reading
    break;
  case 0x5D: //Formerly ], now does A1 ADC
    voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
    lcd.print(voltage2, 3);
    rxbyte = 0x76;           //will cause v to be displayed
    ignoreCNT = ignoreMAX;   //ignore characters replaced by ADC reading
    updateFlag = false;      //reset ADC update flag
    rowA1 = row;             //store row of A1 reading
    colA1 = col;             //store col of A1 reading
    break;
  case 0xE4: //ASCII "a" umlaut
    rxbyte = 0xE1;
    break;
  case 0xF1: //ASCII "n" tilde
    rxbyte = 0xEE;
    break;
  case 0xF6: //ASCII "o" umlaut
    rxbyte = 0xEF; //was wrong in v0.86
    break;
  case 0xFC: //ASCII "u" umlaut
    rxbyte = 0xF5;
    break;

    //accented -> plain equivalent
    //and misc symbol translation
  case 0xA3: //sterling (pounds)
    rxbyte = 0xED;
    break;
    /* case 0xB0: //degrees symbol
     rxbyte = 0xDF;
     break;
     */
  case 0xB5: //mu
    rxbyte = 0xE4;
    break;
  case 0xC0: //"A" variants
  case 0xC1:
  case 0xC2:
  case 0xC3:
  case 0xC4:
  case 0xC5:
    rxbyte = 0x41;
    break;
  case 0xC8: //"E" variants
  case 0xC9:
  case 0xCA:
  case 0xCB:
    rxbyte = 0x45;
    break;
  case 0xCC: //"I" variants
  case 0xCD:
  case 0xCE:
  case 0xCF:
    rxbyte = 0x49;
    break;
  case 0xD1: //"N" tilde -> plain "N"
    rxbyte = 0x43;
    break;
  case 0xD2: //"O" variants
  case 0xD3:
  case 0xD4:
  case 0xD5:
  case 0xD6:
  case 0xD8:
    rxbyte = 0x4F;
    break;
  case 0xD9: //"U" variants
  case 0xDA:
  case 0xDB:
  case 0xDC:
    rxbyte = 0x55;
    break;
  case 0xDD: //"Y" acute -> "Y"
    rxbyte = 0x59;
    break;
    /*  case 0xDF: //beta  //mucks up LCDSmartie's degree symbol??
     rxbyte = 0xE2;
     break;
     */
  case 0xE0: //"a" variants except umlaut
  case 0xE1:
  case 0xE2:
  case 0xE3:
  case 0xE5:
    rxbyte = 0x61;
    break;
  case 0xE7: //"c" cedilla -> "c"
    rxbyte = 0x63;
    break;
  case 0xE8: //"e" variants
  case 0xE9:
  case 0xEA:
  case 0xEB:
    rxbyte = 0x65;
    break;
  case 0xEC: //"i" variants
  case 0xED:
  case 0xEE:
  case 0xEF:
    rxbyte = 0x69;
    break;
  case 0xF2: //"o" variants except umlaut
  case 0xF3:
  case 0xF4:
  case 0xF5:
  case 0xF8:
    rxbyte = 0x6F;
    break;
  case 0xF7: //division symbol
    rxbyte = 0xFD;
    break;
  case 0xF9: //"u" variants except umlaut
  case 0xFA:
  case 0xFB:
    rxbyte = 0x75;
    break;
  default:
    break;
  }
  if(ignoreCNT > 0){
    ignoreCNT--;
  }
  if(ignoreCNT == 0){
    col++;              //increment column position counter
    if(LCDpwr){
      lcd.write(rxbyte);  //otherwise a plain char so we print it to lcd
    }
  }
}


//the following function is the ISR that responds to the push button switch
//it commands the door to open or close at slow speed
void SW_ISR(){
  //debounce the switch by ignoring any interrupt that occurs too soon after the prior one
  unsigned long Time = millis();
  if((Time - SWtime > DBdelay) && (Time > SWtime)){//enough time has elapsed, not a bounce
    SWtime = Time;                                 //save new time of switch push
    doorOPEN = !doorOPEN;                          //reverse desired door state
    if(doorOPEN == true){
      digitalWrite(LEDPIN, HIGH);                  //turn LED on
      myServo.slowmove(posOpenCMD, slowSPD);       //tell servo to go to open position
    }
    else {
      digitalWrite(LEDPIN, LOW);                   //turn LED off
      myServo.slowmove(posCloseCMD, slowSPD);      //tell servo to go to closed position
    }
  }
}


//this function is used by the smartie code to get data from the PC
byte serial_getch(){
  int incoming;
  while (Serial.available()==0){
    //check to see if LCD has power or not
    //initialize if it does, disable outputs if it doesnt
    checkLCD();
    //check to see if enough time has passed since last message from PC
    if((millis() - MSGtime > wait) && (updateFlag == true)){
      updateADC();
    }
  }
  // read the incoming byte:
  incoming = Serial.read();
  return (byte) (incoming &0xff);
}


//this function will update the ADC readings if the [ or ] have been sent
void updateADC(){
  updateFlag = false;
  if(colA0 > 0){
    voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
    lcd.setCursor(colA0, rowA0);
    lcd.print(voltage1, 3);
  }
  if(colA1 > 0){
    voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
    lcd.setCursor(colA1, rowA1);
    lcd.print(voltage2, 3);
  }
}


//This function will determine if the LCD has power. If true then the I/O pins 
//to the LCD will be setup and enabled. If not then the pins will be set to inputs
void checkLCD(){
  if(analogRead(A3) > 500){
    //power is present, enable all outputs
    LCDpwr = true;
    //enable pins for backlight control
    pinMode(redPIN, OUTPUT);
    pinMode(greenPIN, OUTPUT);
    pinMode(bluePIN, OUTPUT);
    analogWrite(bluePIN,0);                //Blue brightness 255-0
    analogWrite(redPIN,255);               //Red brightness 255-0
    analogWrite(greenPIN,255);             //Green brightness 255-0
    //enable pins to write to LCD
    pinMode(rsPIN, OUTPUT);
    pinMode(enablePIN, OUTPUT);
    pinMode(d4PIN, OUTPUT);
    pinMode(d5PIN, OUTPUT);
    pinMode(d6PIN, OUTPUT);
    pinMode(d7PIN, OUTPUT);
    //initialize display after any power-up
    lcd.begin(numCols, numRows);
  }
  else{
    //power is not present, disable all output
    LCDpwr = false;
    //disable pins for backlight control
    pinMode(redPIN, INPUT);
    pinMode(greenPIN, INPUT);
    pinMode(bluePIN, INPUT);
    //disable pins to write to LCD
    pinMode(rsPIN, INPUT);
    pinMode(enablePIN, INPUT);
    pinMode(d4PIN, INPUT);
    pinMode(d5PIN, INPUT);
    pinMode(d6PIN, INPUT);
    pinMode(d7PIN, INPUT);
  }
}

There’s perhaps a little more to do but let’s see this works first.