CCCPaste

"Sensor Display" rev_01

/********* 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: "Sensor Display"
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2024-07-10 18:08:20

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Create a project to display sensor data on a 1602 */
	/* LCD via I2C using the LiquidCrystal_I2C library. */
	/* Configure I2C pins (SDA: A4, SCL: A5) and set the */
	/* slave address to 39. Implement setup and loop */
	/* functions for continuous data update. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include   //https://github.com/marcoschwartz/LiquidCrystal_I2C

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF I2C PINS *****/
const uint8_t ledde_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
const uint8_t ledde_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
const uint8_t ledde_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // I2C address for the LCD

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
LiquidCrystal_I2C lcd(ledde_LCD1602I2C_I2C_SLAVE_ADDRESS, 16, 2); // Initialize the LCD with I2C address and dimensions

void setup(void)
{
  // Initialize the LCD
  lcd.init();
  
  // Turn on the backlight
  lcd.backlight();
  
  // Set the cursor to column 0, line 0 and print a message
  lcd.setCursor(0, 0);
  lcd.print("Sensor Data:");
}

void loop(void)
{
  // Simulate sensor data
  int sensorValue = analogRead(A0); // Read the sensor value from analog pin A0
  
  // Set the cursor to column 0, line 1 and print the sensor value
  lcd.setCursor(0, 1);
  lcd.print("Value: ");
  lcd.print(sensorValue);
  
  // Wait for a short period before updating again
  delay(1000); // Update every second
}

/* END CODE */