Advertisement
pleasedontcode

Scanner rev_83

Nov 1st, 2023
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Scanner
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-01 19:48:35
  15.     - Source Code generated by: AlexWind
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <DS18B20.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* if temperature is > 50°C so activate the relay for */
  24. /* 45,5 seconds and then deactivate. */
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29.  
  30. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  31. const uint8_t temperature_DS18B20_DQ_PIN_D2 = 2;
  32.  
  33. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  34. const uint8_t relay_PIN_D3 = 3;
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  37. DS18B20 ds(temperature_DS18B20_DQ_PIN_D2);
  38.  
  39. void setup(void)
  40. {
  41.   // put your setup code here, to run once:
  42.   pinMode(relay_PIN_D3, OUTPUT);
  43. }
  44.  
  45. void loop(void)
  46. {
  47.   // put your main code here, to run repeatedly:
  48.   float temperature = ds.getTempC();
  49.  
  50.   if (temperature > 50.0)
  51.   {
  52.     digitalWrite(relay_PIN_D3, HIGH); // Activate the relay
  53.     delay(45500); // Wait for 45.5 seconds
  54.     digitalWrite(relay_PIN_D3, LOW); // Deactivate the relay
  55.   }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement