This shows you the differences between two versions of the page.
pm:prj2024:vstoica:rardu_marian.leanca [2024/05/27 03:43] radu_marian.leanca [Bibliografie/Resurse] |
pm:prj2024:vstoica:rardu_marian.leanca [2024/05/27 17:18] (current) radu_marian.leanca [Download] |
||
---|---|---|---|
Line 174: | Line 174: | ||
myDFPlayer.volume(30); // Set volume value (0~30). | myDFPlayer.volume(30); // Set volume value (0~30). | ||
- | // Set pin modes | + | // Set pin modes using direct register manipulation |
- | pinMode(trigPin, OUTPUT); | + | DDRB |= (1 << DDB1); // pumpPin (PB1/Pin 9) |
- | pinMode(echoPin, INPUT); | + | DDRD |= (1 << DDD7); // waterSensorPower (PD7/Pin 7) |
- | pinMode(waterSensorPower, OUTPUT); | + | DDRD |= (1 << DDD6); // soilMoisturePower (PD6/Pin 6) |
- | pinMode(soilMoisturePower, OUTPUT); | + | DDRB |= (1 << DDB0); // trigPin (PB0/Pin 8) |
- | pinMode(pumpPin, OUTPUT); | + | DDRB &= ~(1 << DDB1); // echoPin (PB1/Pin 9) |
analogWrite(pumpPin, 0); | analogWrite(pumpPin, 0); | ||
} | } | ||
Line 230: | Line 230: | ||
void measureDistance() { | void measureDistance() { | ||
// Clear the trigPin | // Clear the trigPin | ||
- | digitalWrite(trigPin, LOW); | + | PORTB &= ~(1 << PORTB0); |
delayMicroseconds(2); | delayMicroseconds(2); | ||
// Set the trigPin high for 10 microseconds | // Set the trigPin high for 10 microseconds | ||
- | digitalWrite(trigPin, HIGH); | + | PORTB |= (1 << PORTB0); |
delayMicroseconds(10); | delayMicroseconds(10); | ||
- | digitalWrite(trigPin, LOW); | + | PORTB &= ~(1 << PORTB0); |
// Read the echoPin and calculate the duration of the pulse | // Read the echoPin and calculate the duration of the pulse | ||
Line 247: | Line 247: | ||
void measureWaterLevel() { | void measureWaterLevel() { | ||
// Power on the water level sensor | // Power on the water level sensor | ||
- | digitalWrite(waterSensorPower, HIGH); | + | PORTD |= (1 << PORTD7); |
delay(10); | delay(10); | ||
Line 253: | Line 253: | ||
// Power off the water level sensor | // Power off the water level sensor | ||
- | digitalWrite(waterSensorPower, LOW); | + | PORTD &= ~(1 << PORTD7); |
} | } | ||
void measureSoilMoisture() { | void measureSoilMoisture() { | ||
// Power on the soil moisture sensor | // Power on the soil moisture sensor | ||
- | digitalWrite(soilMoisturePower, HIGH); | + | PORTD |= (1 << PORTD6); |
delay(10); | delay(10); | ||
Line 264: | Line 264: | ||
// Power off the soil moisture sensor | // Power off the soil moisture sensor | ||
- | digitalWrite(soilMoisturePower, LOW); | + | PORTD &= ~(1 << PORTD6); |
} | } | ||
- | |||
</code> | </code> | ||
Line 283: | Line 282: | ||
===== Download ===== | ===== Download ===== | ||
- | {{:pm:prj2024:vstoica:sswp.zip|}} | + | {{:pm:prj2024:vstoica:sswp_reg.zip|}} |
===== Bibliografie/Resurse ===== | ===== Bibliografie/Resurse ===== | ||
* Resurse Hardware: | * Resurse Hardware: | ||
- | * fișiere 3D: [[https://www.thingiverse.com/thing:3537287]] | + | * [[https://www.thingiverse.com/thing:3537287|fișiere 3D]] |
* Resurse Software: | * Resurse Software: | ||
- | * Senzor ultrasunet: [[https://projecthub.arduino.cc/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-7cabe1]] | + | * [[https://projecthub.arduino.cc/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-7cabe1|Senzor ultrasunet]] |
- | * Senzor nivel apă: [[https://www.instructables.com/How-to-use-a-Water-Level-Sensor-Arduino-Tutorial/]] | + | * [[https://www.instructables.com/How-to-use-a-Water-Level-Sensor-Arduino-Tutorial/|Senzor nivel apă]] |
- | * Senzor sol: [[https://www.dfrobot.com/product-599.html]] | + | * [[https://www.dfrobot.com/product-599.html|Senzor sol]] |
- | * DFPlayer Mini: [[https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299]] | + | * [[https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299|DFPlayer Mini]] |