CCCPaste

Button Monitor rev_04

/********* 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: Button Monitor
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-01-24 22:31:20

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* if button is pressed so print hello on serial */
	/* monitor */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include  //https://github.com/evert-arias/EasyButton
#include     //https://github.com/matmunk/DS18B20

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

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_PushButton_PIN_D2 = 2;
const uint8_t temp_DS18B20_DQ_PIN_D3 = 3;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/

EasyButton button(button_PushButton_PIN_D2);
DS18B20 sensor(temp_DS18B20_DQ_PIN_D3);

void setup(void)
{
  // put your setup code here, to run once:
  pinMode(button_PushButton_PIN_D2, INPUT_PULLUP);
  pinMode(temp_DS18B20_DQ_PIN_D3, INPUT);

  // Initialize the button
  button.begin();

  // Initialize the DS18B20 sensor
  uint8_t address[8];
  sensor.getAddress(address);
  sensor.select(address);

  // Start the serial communication
  Serial.begin(9600);
}

void loop(void)
{
  // put your main code here, to run repeatedly:

  // Read the button state
  button.read();

  // Check if the button is pressed
  if (button.isPressed())
  {
    // Print "Hello" to the serial monitor
    Serial.println("Hello");
  }

  // Read the temperature from the DS18B20 sensor
  float temperature = sensor.getTempC();

  // Print the temperature to the serial monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  delay(1000);
}