/********* 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: Scanner - Source Code compiled for: Arduino Pro Mini 3.3V - Source Code created on: 2023-11-07 14:59:33 - Source Code generated by: AlexWind ********* Pleasedontcode.com **********/ /****** DEFINITION OF LIBRARIES *****/ #include #include #include /****** SYSTEM REQUIREMENT 1 *****/ /* every time the button is pressed 3 times, so read */ /* sensor and provide information on serial monitor. */ /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t pulsante_PushButton_PIN_D3 = 3; const uint8_t sensor_DS18B20_DQ_PIN_D5 = 5; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t led_LED_PIN_D2 = 2; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton button(pulsante_PushButton_PIN_D3); DS18B20 sensor(sensor_DS18B20_DQ_PIN_D5); // Counter for button presses uint8_t buttonPressCount = 0; void setup(void) { // put your setup code here, to run once: pinMode(pulsante_PushButton_PIN_D3, INPUT_PULLUP); pinMode(sensor_DS18B20_DQ_PIN_D5, INPUT); pinMode(led_LED_PIN_D2, OUTPUT); // Initialize the button button.begin(); // Start serial communication Serial.begin(9600); } void loop(void) { // put your main code here, to run repeatedly: button.read(); // Check if the button was pressed if (button.wasPressed()) { // Increment the button press count buttonPressCount++; // Check if the button was pressed 3 times if (buttonPressCount == 3) { // Read the temperature from the sensor float temperature = sensor.getTempC(); // Print the temperature on the serial monitor Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C"); // Reset the button press count buttonPressCount = 0; } } }