/* e-Gizmo LCD Shield & keypad shield v1 This is a simple sample code for the sample demonstration of LCD (2x16),(4x20) Display and keypad matrix connections. Also with on board buttons and a +5v buzzer included. This LCD Shield is compatible in gizDuino (plus) ATmega644p and gizDuino (x) ATmega1281p. The circuit: *gizDuino 328 == 644 and X * LCD RS pin to digital pin 12 == pin 26 * LCD Enable pin to digital pin 11 == pin 27 * LCD D4 pin to digital pin 5 == pin 28 * LCD D5 pin to digital pin 4 == pin 29 * LCD D6 pin to digital pin 3 == pin 30 * LCD D7 pin to digital pin 2 == pin 31 * LCD R/W pin to ground * LCD VSS pin to ground * LCD VCC pin to 5V * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/LiquidCrystal by e-Gizmo Mechatronix Central http://www.e-gizmo.com November 12, 2015 modified */ #include //Selection of LiquidCrystal pins //LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //gizDuino 328 or gizduino V LiquidCrystal lcd(26, 27, 28, 29, 30, 31); //default pin assign (644 and X) //Buttons pins assignment #define button_S2 18 #define button_S3 17 #define button_S4 16 #define button_S5 15 #define button_S6 14 //set the buttons on HIGH state int buttonS2_state = 1; int buttonS3_state = 1; int buttonS4_state = 1; int buttonS5_state = 1; int buttonS6_state = 1; boolean clr =false; void setup(){ //Selection of LCD begin characters //lcd.begin(16,2); // set lcd in 16x2 characters lcd.begin(20,4); // set lcd in 20x4 characters lcd.setCursor(0,0); // set the cursor in (0,0) /(COL,ROW) to begin lcd.print("LCD Shield"); // print a message to the LCD. //Initialize button pins as an INPUT. //INPUT_PULLUP or HIGH pinMode(button_S2, INPUT_PULLUP); pinMode(button_S3, INPUT_PULLUP); pinMode(button_S4, INPUT_PULLUP); pinMode(button_S5, INPUT_PULLUP); pinMode(button_S6, INPUT_PULLUP); } void loop(){ //read the state of the pushbutton value: int buttonS2_state = digitalRead(button_S2); int buttonS3_state = digitalRead(button_S3); int buttonS4_state = digitalRead(button_S4); int buttonS5_state = digitalRead(button_S5); int buttonS6_state = digitalRead(button_S6); // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0,1); // check if the pushbutton is pressed. // if it is, the buttonState is LOW: if(buttonS2_state == 0){ lcd.print("button_S2"); //print a message to the LCD //delay(1000); //wait for a second } if(buttonS3_state == 0){ lcd.print("button_S3"); //delay(1000); } if(buttonS4_state == 0){ lcd.print("button_S4"); //delay(1000); } if(buttonS5_state == 0){ lcd.print("button_S5"); //delay(1000); } if(buttonS6_state == 0){ lcd.print("button_S6"); //delay(1000); } clr = true; if(clr == true){ lcd.print(" "); //clear the message to the LCD } }