Components and supplies
1
Alphanumeric LCD, 16 x 2
1
Arduino UNO
1
Jumper wires (generic)
Project description
Code
Code file
c_cpp
1#include <LiquidCrystal_I2C.h> 2 3LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 4 5 6void setup() { 7 lcd.begin(16,2); 8} 9 10void loop() { 11 count_countdown(); 12 delay(600); 13 scroll_left(); 14 delay(600); 15 scroll_right(); 16} 17 18//Displays the numbers from 0 to 9 19void count_countdown(){ 20 lcd.setCursor(0,0); 21 for (int thisChar = 0; thisChar < 10; thisChar++) { 22 lcd.print(thisChar); 23 delay(500); 24 } 25 //Changes line and displays the numbers from 9 to 0 26 lcd.setCursor(0,1); 27 for (int thisChar =9; thisChar>=0; thisChar--) { 28 lcd.print(thisChar); 29 delay(500); 30 } 31 } 32 33//Scrolls message from left to right 34void scroll_left(){ 35 lcd.begin(16, 2); 36 lcd.print("Scrolling message!"); 37 delay(1000); 38 for (int positionCounter = 0; positionCounter < 18; positionCounter++) { 39 // scroll one position left: 40 lcd.scrollDisplayLeft(); 41 // wait a bit: 42 delay(150); 43 } 44 delay(600); 45} 46 47//Scrolls message from right to left 48void scroll_right(){ 49 lcd.begin(16, 2); 50 lcd.print("Scrolling message!"); 51 delay(1000); 52 for (int positionCounter = 0; positionCounter < 20; positionCounter++) { 53 // scroll one position right: 54 lcd.scrollDisplayRight(); 55 // wait a bit: 56 delay(150); 57 } 58 delay(600); 59 }
Code file
c_cpp
1#include <LiquidCrystal_I2C.h> 2 3LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 4 5 6void setup() { 7 lcd.begin(16,2); 8} 9 10void loop() { 11 count_countdown(); 12 delay(600); 13 scroll_left(); 14 delay(600); 15 scroll_right(); 16} 17 18//Displays the numbers from 0 to 9 19void count_countdown(){ 20 lcd.setCursor(0,0); 21 for (int thisChar = 0; thisChar < 10; thisChar++) { 22 lcd.print(thisChar); 23 delay(500); 24 } 25 //Changes line and displays the numbers from 9 to 0 26 lcd.setCursor(0,1); 27 for (int thisChar =9; thisChar>=0; thisChar--) { 28 lcd.print(thisChar); 29 delay(500); 30 } 31 } 32 33//Scrolls message from left to right 34void scroll_left(){ 35 lcd.begin(16, 2); 36 lcd.print("Scrolling message!"); 37 delay(1000); 38 for (int positionCounter = 0; positionCounter < 18; positionCounter++) { 39 // scroll one position left: 40 lcd.scrollDisplayLeft(); 41 // wait a bit: 42 delay(150); 43 } 44 delay(600); 45} 46 47//Scrolls message from right to left 48void scroll_right(){ 49 lcd.begin(16, 2); 50 lcd.print("Scrolling message!"); 51 delay(1000); 52 for (int positionCounter = 0; positionCounter < 20; positionCounter++) { 53 // scroll one position right: 54 lcd.scrollDisplayRight(); 55 // wait a bit: 56 delay(150); 57 } 58 delay(600); 59 }
Downloadable files
circuit_kb0nv8rtxs.fzz
circuit_kb0nv8rtxs.fzz
Comments
Only logged in users can leave comments