Implement pump control via port register
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "moisture.h"
|
||||
#include "adc.h"
|
||||
#include "moisture.h"
|
||||
#include "pump.h"
|
||||
|
||||
|
||||
|
||||
ISR(WDT_vect) {
|
||||
triggerRead();
|
||||
@@ -27,8 +30,8 @@ void enterSleep(void) {
|
||||
|
||||
void setup(void) {
|
||||
adcInit();
|
||||
//pumpsInit();
|
||||
sensorsInit();
|
||||
//pumpsInit();
|
||||
watchdogs();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,17 +10,15 @@ void pumpsInit(void) {
|
||||
(1 << PUMP_D4) |
|
||||
(1 << PUMP_D3) |
|
||||
0 | 0 | 0 ));
|
||||
// Disable pullup
|
||||
PORTD &= ~((1 << PUMP_D7) |
|
||||
(1 << PUMP_D6) |
|
||||
(1 << PUMP_D5) |
|
||||
(1 << PUMP_D4) |
|
||||
(1 << PUMP_D3) |
|
||||
0 | 0 | 0 ));
|
||||
}
|
||||
|
||||
void triggerPump(int8_t pump_pin, int16_t milliseconds) {
|
||||
// turn on pump
|
||||
// watchdog for n milliseconds
|
||||
// turn of pump
|
||||
// Turn on pump
|
||||
PORTD |= (1 << pump_pin);
|
||||
|
||||
// timer for n milliseconds
|
||||
// NOTE: watchout for overflows!! create a safety net.
|
||||
|
||||
// Turn off pump
|
||||
PORTD &= ~(1 << pump_pin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user