Advertisement
pleasedontcode

Scrolling Text rev_01

May 4th, 2024
847
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 NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-04 15:12: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. /****** DEFINITION OF LIBRARIES *****/
  25. #include <Wire.h>
  26. #include <LiquidCrystal_I2C.h>  // https://github.com/marcoschwartz/LiquidCrystal_I2C
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF I2C PINS *****/
  33. const uint8_t LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  34. const uint8_t LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  35. const uint8_t LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // This is the I2C address, not 39
  36.  
  37. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  38. LiquidCrystal_I2C lcd(LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // Initialize the LCD object with the correct I2C address, columns, and rows
  39.  
  40. int position = 0; // Variable to store the position of the displayed text
  41.  
  42. void setup(void)
  43. {
  44.   // put your setup code here, to run once:
  45.   lcd.init();
  46.   lcd.backlight();
  47.   lcd.setCursor(0, 0);
  48.   lcd.print("Your Name:"); // Display a label
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // put your main code here, to run repeatedly:
  54.   lcd.setCursor(position, 1); // Set the cursor position for displaying name
  55.   lcd.print("Your Name"); // Display your name
  56.  
  57.   delay(300); // Delay for smooth movement
  58.  
  59.   lcd.setCursor(position, 1); // Clear the previous name
  60.   lcd.print("          "); // Print spaces to clear the name
  61.  
  62.   if (position < 14) {
  63.     position++; // Move the text to the right
  64.   } else {
  65.     position = 0; // Reset position to start from the left
  66.   }
  67. }
  68.  
  69. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement