Devices & Components
16x2 LCD display with I²C interface
Arduino Nano
Pushbutton switch 12mm
Resistor 1M ohm
Project description
Code
Here is the code
arduino
1//Include the LCD Library. 2#include <Wire.h> 3#include <LiquidCrystal_I2C.h> 4 5LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 6 7 8const int buttonPin1 = 2; // Charachter change button 9const int buttonPin2 = 3; // Move button 10const int buttonPin3 = 4; // Reset screen button 11const char chars[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','.',',','1','2','3','4','5','6','7','8','9','0','-','*','@','!','$','&','(',')'};//add any additional characters 12 13int charindex = 0; 14int buttonState1 = 0; 15int buttonState2 = 0; 16int buttonState3 = 0; 17int charsSize = 0; 18int cx = 0; 19int cy = 0; 20 21 22 23void setup() { 24 //init LCD 25 lcd.begin(16,2); 26 lcd.print("ARDUINO TYPE"); 27 lcd.setCursor(2,4); 28 lcd.print("WRITER"); 29 delay(2000); 30 lcd.clear(); 31 lcd.setCursor(0, 0); 32 lcd.blink(); 33 //Charachters array size 34 charsSize = sizeof(chars); 35 //LED init 36 // initialize the pushbutton pin as an input: 37 pinMode(buttonPin1, INPUT); 38 pinMode(buttonPin2, INPUT); 39 pinMode(buttonPin3, INPUT); 40 41 42} 43 44void loop() { 45 buttonState1 = digitalRead(buttonPin1); 46 buttonState2 = digitalRead(buttonPin2); 47 buttonState3 = digitalRead(buttonPin3); 48 // 49 if (buttonState1 == HIGH) { 50 if(charindex == charsSize){ 51 charindex = 0; 52 } 53 // change char and turn led on: 54 55 lcd.print(chars[charindex]); 56 lcd.setCursor(cx, cy); 57 charindex++; 58 } else { 59 60 } 61 //Move to next pixel 62 if (buttonState2 == HIGH) { 63 64 charindex = 0; 65 cx++; 66 if(cx == 16){ 67 cx = 0; 68 cy++; 69 } 70 if(cy == 2){ 71 cy = 0; 72 } 73 lcd.setCursor(cx, cy); 74 }else { 75 76 } 77 //reset 78 if (buttonState3 == HIGH) { 79 80 charindex = 0; 81 cx = 0; 82 cy = 0; 83 lcd.setCursor(cx, cy); 84 lcd.clear(); 85 }else { 86 87 } 88 delay(170); 89} 90
Downloadable files
Here is the schematics
Here is the schematics

Here is the schematics
Here is the schematics

Comments
Only logged in users can leave comments