click here to enter

LCD display - Kingston hackSpace

Kingston hackSpace

LCD display

Liquid Crystal Display (LCD) is a type of alphanumeric or graphic display based on liquid crystals. LCDs are available in many different sizes, shapes and styles. In hackSpace we have the standard HD44780 LCD, which have 16 columns and 2 rows, for a total of 32 characters. The text is displayed on white and the background is blue. The single LED used in the display can be dimmed easily using a potentiometer or PWM, it uses less powered than LCD with EL (electroluminescent) backlight. These sorts of displays are used with machines or microcontrollers to measure data or distance of a specific component, however nowadays OLEDs are taking control of the market.


/*
http://kingstonhack.space

displays a random number on the LCD display

*/

#include 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 6;     // the number of the pushbutton pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int nextbuttonPressed = 1;

String text1;
String text2;

void setup() {
  // initialize the LED pin as an output:
  //pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  randomSeed(analogRead(0));

  lcd.begin(16, 2);
}

void loop() {

  lcd.setCursor(0, 0);
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH && nextbuttonPressed <= 0) {
    text1 = ("ID#");
    text2 = String(random(1000,9999));

    lcd.print(text1 + text2 );
    
    nextbuttonPressed = 100;
    // turn LED on:
    //digitalWrite(ledPin, HIGH);
  } else {
    nextbuttonPressed -= 1;  
    // turn LED off:
    //digitalWrite(ledPin, LOW);
  }
  delay(10);
}


To borrow this component, click here