Using 16x2 display without potentiometer, weird issue with button occuring

Hi there! I'm currently working on a school project that involves a fingerprint sensor. I had the bright idea of having the fingerprint sensor unlock passwords on a 16x2 screen that can be cycled through with a button. I'm using code from another project I worked on that allowed a user to cycle through shortened quick links to websites to create this, so my code has no inclusion of a fingerprint sensor yet.

However, I noticed that the fingerprint sensor module I have needs to be connected to the GND and 5V on the Arduino itself, and my 16x2's potentiometer was there. I followed this guide on having my display function without it. Now, the screen displays nothing when the new code is run, and the button presses just make the screen act weird. I have attached a video of the issue here and have my code below.

#include <LiquidCrystal.h>
int Contrast = 60;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const byte buttonPin1 = 10;


int Counter = 0;
boolean btnState1 = LOW;
boolean lastState1 = LOW;


void setup()
{
  Serial.begin(9600);
  analogWrite(6,Contrast);
  lcd.begin(16, 2);
  lcd.print("Locked");
  pinMode(buttonPin1, INPUT);
}


void loop()
{
  btnState1 = digitalRead(buttonPin1);
  if (btnState1 != lastState1)
  {
    if (btnState1 == HIGH)
    {
      Counter++;
      lcd.clear();  
      if (Counter > 3)                              
      {
        Counter = 1;
      }
      Serial.println(Counter);
      switch (Counter)
      {
        case 0:
          lcd.print("Passwords");
          break;
        case 1:
          lcd.print("Email");
          break;
        case 2:
          lcd.print("Banking");
          break;
        case 3:
          lcd.print("idk porn?");
          break;
      }
    }
    lastState1 = btnState1;

  }
}

What is the problem with both between 5V and GND? Mostly there where more components that uses the same power lines.

Quick tips.

  1. You should connect the LCD to power as originally planned. You can connect the 5V to both devices without problems.

  2. you may want to use INPUT_PULLUP for your button's pinMode unless you have an external pullup resistor.

  3. you should reset your counter to 0, not 1 so you can get to your passwords.

  4. my browser seems to block requests to option #3. hmmmm.

I was just waiting for someone to point out my temp code to me :joy: at least I kept my OnlyFans password off the public code this time... :smile:

How exactly can I have both attached at once? As far as I'm aware the documentation for this sensor wants the 5V attached directly to the Arduino rather than the breadboard, which is odd.

Yeah, this code is from another project and a solid half of it is missing, therefore the code may seem a tad wonky but I was merely seeing if it powered on with the module attached.

ha.

regarding the 5V. it doesn't matter where you tap into it - it all comes from the same source as long as they are all tied together - and the grounds too!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.