/********* 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: "Temperature-controlled Servo" - Source Code compiled for: Arduino Uno - Source Code created on: 2024-02-15 17:55:04 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Отрегулируйте положение серводвигателя на контакте */ /* D3 под углом 90 градусов, когда температура */ /* DS18B20 обнаруженная датчиком, достигнет 30 */ /* градусов по Цельсию. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include //https://github.com/arduino-libraries/Servo #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t sensor_DS18B20_DQ_PIN_D2 = 2; /***** DEFINITION OF PWM OUTPUT PINS *****/ const uint8_t motor_Servomotor_PWMSignal_PIN_D3 = 3; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ uint8_t motor_Servomotor_PWMSignal_PIN_D3_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float motor_Servomotor_PWMSignal_PIN_D3_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ Servo myservo; OneWire oneWire(sensor_DS18B20_DQ_PIN_D2); DallasTemperature sensors(&oneWire); void setup(void) { // put your setup code here, to run once: pinMode(sensor_DS18B20_DQ_PIN_D2, INPUT); pinMode(motor_Servomotor_PWMSignal_PIN_D3, OUTPUT); myservo.attach(motor_Servomotor_PWMSignal_PIN_D3); // Initialize servo sensors.begin(); // Initialize DS18B20 sensor } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data } void updateOutputs(void) { sensors.requestTemperatures(); // Request temperature from DS18B20 sensor float temperature = sensors.getTempCByIndex(0); // Read temperature from DS18B20 sensor if (temperature >= 30) { myservo.write(90); // Set servo position to 90 degrees } else { myservo.write(0); // Set servo position to 0 degrees } }