Beruflich Dokumente
Kultur Dokumente
// Constants
const int windSpeedThreshold = 10; // Adjust this value based on the system
const int lightThreshold = 1023 * 0.25; // 25% of full scale for the light sensor
const int motorRunTime = 10000; // 10 seconds for motor operation
// Variables
bool userOverride = true; // Initial state allowing user control
void setup() {
// Setup pins
pinMode(openButtonPin, INPUT_PULLUP);
pinMode(closeButtonPin, INPUT_PULLUP);
pinMode(mEnablePin, OUTPUT);
pinMode(mDirPin, OUTPUT);
void loop() {
// Check user buttons
if (userOverride) {
if (digitalRead(openButtonPin) == LOW) {
operateMotor(HIGH); // Open awning
} else if (digitalRead(closeButtonPin) == LOW) {
operateMotor(LOW); // Close awning
}
}
bool checkWindSpeed() {
int windFrequency = pulseIn(windPin, HIGH); // Measure pulse frequency
bool checkLightLevel() {
int lightLevel = analogRead(solarPin);