CCCPaste

LED Control 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: LED Control
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-04-10 11:14:03

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* This code will consider a hospital set up where a */
	/* person is isolated and under medical observation */
	/* create a program that mimics a blood pressure */
	/* monitoring system if the person's BP reading is */
	/* above 200,lit a red light in the remote control */
	/* room and */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 

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

/***** DEFINITION OF ANALOG INPUT PINS *****/
const uint8_t POT_Potentiometer_Vout_PIN_A0 = A0;

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t LED_LED_PIN_D2 = 2;

/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool LED_LED_PIN_D2_rawData = 0;

/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float LED_LED_PIN_D2_phyData = 0.0;

void setup(void)
{
  // put your setup code here, to run once:
  pinMode(POT_Potentiometer_Vout_PIN_A0, INPUT);
  pinMode(LED_LED_PIN_D2, OUTPUT);
  Wire.begin(); // Initialize I2C communication
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  updateOutputs(); // Refresh output data

  // Read the analog value from the potentiometer
  int potValue = analogRead(POT_Potentiometer_Vout_PIN_A0);

  // Convert the analog value to a physical value
  float physicalValue = map(potValue, 0, 1023, 0, 300); // Assuming the potentiometer measures values from 0 to 300

  if (physicalValue > 200)
  {
    LED_LED_PIN_D2_rawData = 1; // Set the raw data to turn on the LED
  }
  else
  {
    LED_LED_PIN_D2_rawData = 0; // Set the raw data to turn off the LED
  }
}

void updateOutputs()
{
  digitalWrite(LED_LED_PIN_D2, LED_LED_PIN_D2_rawData);
}