/********* 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-11 15:23:01 - Source Code generated by: AlexWind ********* Pleasedontcode.com **********/ /****** DEFINITION OF LIBRARIES *****/ #include #include #include #include /****** SYSTEM REQUIREMENT 1 *****/ /* Every time the button is pressed 3 times, read the sensor and provide information on the serial monitor. */ /****** SYSTEM REQUIREMENT 2 *****/ /* If 'H' is received before the character 'o' and then the character 'k', switch off the LED. */ /****** 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 Software Serial *****/ const uint8_t myBluetooth_HC05_mySerial_PIN_SERIAL_TX_A0 = A0; const uint8_t myBluetooth_HC05_mySerial_PIN_SERIAL_RX_A1 = A1; SoftwareSerial myBluetooth_HC05_mySerial(myBluetooth_HC05_mySerial_PIN_SERIAL_RX_A1, myBluetooth_HC05_mySerial_PIN_SERIAL_TX_A0); /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton pulsante_PushButton(pulsante_PushButton_PIN_D3); DS18B20 sensor_DS18B20(sensor_DS18B20_DQ_PIN_D5); // Variables to count button presses int 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); myBluetooth_HC05_mySerial.begin(9600); pulsante_PushButton.begin(); } void loop(void) { // put your main code here, to run repeatedly: pulsante_PushButton.read(); /****** SUBSYSTEM REQUIREMENT 1 *****/ if (pulsante_PushButton.wasPressed()) { // Increment the button press count buttonPressCount++; // Check if the button has been pressed 3 times if (buttonPressCount == 3) { // Read sensor and provide information on serial monitor float temperature = sensor_DS18B20.getTempC(); Serial.print("Temperature: "); Serial.println(temperature); // Reset the button press count buttonPressCount = 0; } } /****** SUBSYSTEM REQUIREMENT 2 *****/ if (myBluetooth_HC05_mySerial.available()) { char c = myBluetooth_HC05_mySerial.read(); if (c == 'H') { // Check if 'o' and 'k' are received after 'H' if (myBluetooth_HC05_mySerial.available() && myBluetooth_HC05_mySerial.read() == 'o') { if (myBluetooth_HC05_mySerial.available() && myBluetooth_HC05_mySerial.read() == 'k') { // Switch off the LED digitalWrite(led_LED_PIN_D2, LOW); } } } } }