Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: Digital Control
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-02-24 07:17:53
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* turn on activebuzzer when humiditi hit below 70% */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* stop activebuzzer when humidity is above 90% */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include "DHT.h"
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t humiditysensor_DHT22_DOUT_PIN_D2 = 2;
- const uint8_t humiditysensor_DHT22_DOUT_PIN_D3 = 3;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t ultrasonichumid_ActiveBuzzer_output_PIN_D4 = 4;
- const uint8_t ultrasonichumid_ActiveBuzzer_output_PIN_D5 = 5;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0;
- bool ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float ultrasonichumid_ActiveBuzzer_output_PIN_D4_phyData = 0.0;
- float ultrasonichumid_ActiveBuzzer_output_PIN_D5_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- DHT dht(humiditysensor_DHT22_DOUT_PIN_D2, DHT22);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(humiditysensor_DHT22_DOUT_PIN_D2, INPUT_PULLUP);
- pinMode(humiditysensor_DHT22_DOUT_PIN_D3, INPUT_PULLUP);
- pinMode(ultrasonichumid_ActiveBuzzer_output_PIN_D4, OUTPUT);
- pinMode(ultrasonichumid_ActiveBuzzer_output_PIN_D5, OUTPUT);
- dht.begin();
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- float humidity = dht.readHumidity();
- if (humidity < 70) {
- ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 1; // turn on active buzzer
- ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
- } else if (humidity > 90) {
- ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0; // stop active buzzer
- ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 0;
- } else {
- ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData = 0;
- ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData = 1;
- }
- updateOutputs(); // Refresh output data
- }
- void updateOutputs(void)
- {
- digitalWrite(ultrasonichumid_ActiveBuzzer_output_PIN_D4, ultrasonichumid_ActiveBuzzer_output_PIN_D4_rawData);
- digitalWrite(ultrasonichumid_ActiveBuzzer_output_PIN_D5, ultrasonichumid_ActiveBuzzer_output_PIN_D5_rawData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement