LCD KeyPad Shield

Today we would like to introduce you to our practical LCD shield with keypad. In our example, we built a small, simple stop clock. We like this shield so much because you can start programming immediately without hardware knowledge, so menu structures or the like can be created in minutes - without buttons, re-enamours or breadboards. 

Bom:

LCD Keypad Shield
AZ-Delivery UnoR3

Code:

 

the required libaryes
#include <Spi.H>
#include <LiquidCrystal.H>

LiquidCrystal Lcd(8, 13, 9, 4, 5, 6, 7); LCD pins for our Shield

Unsigned Long Start, Finished, Elapsed; Global variables


Void Setup()
{   Lcd.Begin(16, 2); Start LCD        Lcd.Print(" -= Arduino =-");   Lcd.setCursor(0,1); set cursor   Lcd.Print(" -= StopClock =- ");   Delay(5000); wait 5 seconds      Lcd.Clear(); clear the display   Lcd.Print("LFT - Start/Rst");   Lcd.setCursor(0,1);   Lcd.Print("SEL - Elap. time");
}

Void displayResult()
{   Local variables   Float H, M, S, Ms;   Unsigned Long Over;   the formula   Elapsed = Finished - Start;      H = Int(Elapsed / 3600000);   Over = Elapsed % 3600000;   M    = Int(Over / 60000);   Over = Over % 60000;   S    = Int(Over / 1000);   Ms   = Over % 1000;   Lcd.setCursor(0,0);   Lcd.Print("Past time:");   Structure for result   Lcd.setCursor(0,1);   Lcd.Print(H, 0);   Lcd.Print("h ");    Lcd.Print(M, 0);   Lcd.Print("m ");   Lcd.Print(S, 0);   Lcd.Print("s ");   Lcd.Print(Ms, 0);   Lcd.Print("ms");
}

Void Loop()
{   Int X; Variable   X = analogRead (0); assign 'x' AnalogueInput (Shield's buttons)   If (X < 600 && X > 400) if button is LEFT   {     Start = millis(); Start     Delay(200); debounce     Lcd.Clear();     Lcd.Print("started...");   }   else If (X < 800 && X > 600) SELECT Button   {     Finished = millis(); for comparison     Delay(200); debounce     Lcd.Clear();     displayResult(); outputs result   }
}

 

DisplaysProduktvorstellungen

1 comment

Hardy

Hardy

Tolle Sache! Wie müsste der Code aussehen wenn,
ich immer die laufende Zeit incl. Hunderstel sehen möchte und 4 Zeiten angezeigt werden sollen:
1.Startzeit (die komplett durchläuft)
2. Zwischenzeit 1
3.Zwischenzeit 2
4.Endzeit

Ich würde gern 4 Lichtschrankensignale zum Auslösen an A0,A1,A2,A3 nutzen. (später sollen die drahtlos übertragen werden…)

Würde mich riesig über den Code freuen!!!

VG Hardy

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN