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: LCD Control
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-10-21 16:39:30
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* When you press the key, the LED turns on */
- /****** 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 Lcd_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
- const uint8_t Lcd_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
- const uint8_t Lcd_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;
- /***** DEFINITION OF LED PIN *****/
- const uint8_t LED_PIN = 13; // Define the pin for the LED
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Initialize the LiquidCrystal_I2C object with the I2C address and dimensions
- LiquidCrystal_I2C lcd(Lcd_LCD1602I2C_I2C_SLAVE_ADDRESS, 20, 4); // 20 columns and 4 rows
- void setup(void)
- {
- // Initialize the LCD
- lcd.init(); // Initialize the LCD
- lcd.backlight(); // Turn on the backlight
- Serial.begin(9600); // Start serial communication at 9600 baud rate
- // Initialize the LED pin as an output
- pinMode(LED_PIN, OUTPUT); // Set LED pin as output
- }
- void loop(void)
- {
- // Check if there is any data available to read from the serial port
- if (Serial.available())
- {
- delay(100); // Short delay to allow data to be fully received
- lcd.clear(); // Clear the LCD display
- while (Serial.available() > 0) // While there is data available
- {
- lcd.write(Serial.read()); // Read and display each character on the LCD
- }
- // Turn on the LED when a key is pressed
- digitalWrite(LED_PIN, HIGH); // Turn on the LED
- delay(1000); // Keep the LED on for 1 second
- digitalWrite(LED_PIN, LOW); // Turn off the LED
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement