Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Scrolling Text
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-05-04 15:13:08
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* display my name on the I2C moving from left to */
- /* right and back */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h> // https://github.com/marcoschwartz/LiquidCrystal_I2C
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t LCD1602I2C_I2C_PIN_SDA_A4 = A4;
- const uint8_t LCD1602I2C_I2C_PIN_SCL_A5 = A5;
- const uint8_t LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // This is the I2C address, not 39
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- LiquidCrystal_I2C lcd(LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // Initialize the LCD object with the correct I2C address, columns, and rows
- int position = 0; // Variable to store the position of the displayed text
- void setup(void)
- {
- // put your setup code here, to run once:
- lcd.init();
- lcd.backlight();
- lcd.setCursor(0, 0);
- lcd.print("Your Name:"); // Display a label
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- lcd.setCursor(position, 1); // Set the cursor position for displaying name
- lcd.print("Your Name"); // Display your name
- delay(300); // Delay for smooth movement
- lcd.setCursor(position, 1); // Clear the previous name
- lcd.print(" "); // Print spaces to clear the name
- if (position < 14) {
- position++; // Move the text to the right
- } else {
- position = 0; // Reset position to start from the left
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement