Advertisement
pleasedontcode

Scrolling Text rev_02

May 4th, 2024
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Scrolling Text
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-04 15:13:08
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* display my name on the I2C moving from left to */
  21.     /* right and back */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Wire.h>
  27. #include <LiquidCrystal_I2C.h>  // https://github.com/marcoschwartz/LiquidCrystal_I2C
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /***** DEFINITION OF I2C PINS *****/
  34. const uint8_t LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  35. const uint8_t LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  36. const uint8_t LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // This is the I2C address, not 39
  37.  
  38. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  39. LiquidCrystal_I2C lcd(LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // Initialize the LCD object with the correct I2C address, columns, and rows
  40.  
  41. int position = 0; // Variable to store the position of the displayed text
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.   lcd.init();
  47.   lcd.backlight();
  48.   lcd.setCursor(0, 0);
  49.   lcd.print("Your Name:"); // Display a label
  50. }
  51.  
  52. void loop(void)
  53. {
  54.   // put your main code here, to run repeatedly:
  55.   lcd.setCursor(position, 1); // Set the cursor position for displaying name
  56.   lcd.print("Your Name"); // Display your name
  57.  
  58.   delay(300); // Delay for smooth movement
  59.  
  60.   lcd.setCursor(position, 1); // Clear the previous name
  61.   lcd.print("          "); // Print spaces to clear the name
  62.  
  63.   if (position < 14) {
  64.     position++; // Move the text to the right
  65.   } else {
  66.     position = 0; // Reset position to start from the left
  67.   }
  68. }
  69.  
  70. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement