/********* 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:32:42
- 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, so read */
/* sensor and provide information on serial monitor. */
/****** SYSTEM REQUIREMENT 2 *****/
/* if HC05 read before the character 'o' and then the */
/* character 'k', so 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 button(pulsante_PushButton_PIN_D3);
DS18B20 sensor(sensor_DS18B20_DQ_PIN_D5);
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);
button.begin();
}
void loop(void)
{
// put your main code here, to run repeatedly:
button.read();
if (button.wasPressed()) {
buttonPressCount++;
if (buttonPressCount == 3) {
// Read the sensor and provide information on serial monitor
float temperature = sensor.getTempC();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
buttonPressCount = 0; // Reset button press count
}
}
if (myBluetooth_HC05_mySerial.available()) {
char c = myBluetooth_HC05_mySerial.read();
if (c == 'o') {
if (myBluetooth_HC05_mySerial.available()) {
char c2 = myBluetooth_HC05_mySerial.read();
if (c2 == 'k') {
digitalWrite(led_LED_PIN_D2, LOW);
}
}
}
}
}