Pinguino + LCD Keypad Shield

Pinguino+Arduino LCD Keypad Shield

Pin Out Diagram:

Pin:

Pin Allocation:


Function:
lcd (rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
lcd.begin (lines, dotsize)
lcd.clear
lcd.home
lcd.print (“string”)
lcd.printNumber (number,base)
lcd.setCursor (column,row)

Example: Clock (Hour/Min/Sec)

Flow Chart:

Program Code:

 

#define LED 13

//global vars
float num;

void setup()
{
	//8 bits mode
	//lcd(8, 9, 0, 1, 2, 3, 4, 5, 6, 7); // RS, E, D0 ~ D7

	//4 bits mode, dont use last four pins ...
	lcd(8, 9, 4, 5, 6, 7, 0, 0, 0, 0); // RS, E, D4 ~ D8	

	//LCD format
	lcd.begin(2, 0);

	/* Debug */
	pinMode(LED, OUTPUT);		// LED on pin 13
}

uchar counter = 0;
uchar sec  = 0;
uchar min  = 0;
uchar hour = 0;
int z;
void loop()
{

	// Output string
	lcd.home();
	lcd.print("Pinguino-LCDlib");	// Output char

	if (counter>9){
		counter = 0;
		sec++;
	}

	if (sec>59){
		sec = 0;
		min++;
	}

	if (min>59){
		min = 0;
		hour++;
	}

	if (hour>23){
		hour = 0;
	}

	lcd.setCursor(0, 1);

	if (hour < 10)
		lcd.print("0");
	lcd.printNumber(hour, 10);

	if (min < 10)
		lcd.print(":0");
	else
		lcd.print(":");
	lcd.printNumber(min, 10);

	if (sec < 10)
		lcd.print(":0");
	else
		lcd.print(":");
	lcd.printNumber(sec, 10);	

	//set hour and min
	z=analogRead(14);

	if (z>50 && z<200)	//hour++
	{
	hour++;
	delay(50);
	} 

	if (z>200 && z<400)	//hour--
	{
	if (hour>0)
	hour--;
	else
	hour = 23;
	delay(50);
	} 

	if (z<50)		//min++
	{
	min++;
	delay(50);
	} 

	if (z>400 && z<600)	//min--
	{
	if (min>0)
	min--;
	else
	min = 59;
	delay(50);
	} 

	if (z>600 && z<800)	//reset sec
	{
	sec=0;
	delay(50);
	} 

	if (z>800)	//nothing
	{
	delay(50);
	} 

	counter++;

	delay(51); //just a fine tune to get 100ms with this!
	digitalWrite(LED, LOW);
	delay(51);
	digitalWrite(LED, HIGH);
}

DEMONSTRATION:

BUY

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorail

Display Temperature and Humidity on OLED using DHT22 and Arduino
Getting Started With Teensy Using Arduino IDE
Night Light
Arduino Device Tracker Using GSM GPS SIM7600E Module
Chocolate Box with Touch Sensor and Arduino
Scroll to Top