I am trying to make an automated watering system using an Arduino.
Here is my wiring diagram: enter image description hereWiring Diagram And here is my circuit wired up: Photo of wired circuit
Here is the code that I'm using with Arduino. The code seems alright and the wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program doesn't run like I coded. After I uploaded this code to Arduino, the water pump just keeps running forever. Can anyone check up my code to make this run properly?
Here is the code that I'm using with Arduino. The code seems alright and the wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program doesn't run like I coded. After I uploaded this code to Arduino, the water pump just keeps running forever. Can anyone check up my code to make this run properly?
I am trying to make an automated watering system using an Arduino.
Here is my wiring diagram: Wiring Diagram And here is my circuit wired up: Photo of wired circuit
Here is the code that I'm using with Arduino. The code seems alright and the wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program doesn't run like I coded. After I uploaded this code to Arduino, the water pump just keeps running forever. Can anyone check up my code to make this run properly?
- 1.6k
- 1
- 12
- 17
I am making Making an automated watering system with Arduino
enter image description here Here
Here is the code whatthat I'm applying tousing with Arduino. CodeThe code seems alright and, the wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program, it doesn't run like iI coded. After I applieduploaded this code to Arduino, the water pump is just keepkeeps running forever. Can anyone check up my code to make this run properly?
/**automatated**automated watering program **/
#include <avr/sleep.h>
#include <avr/wdt.h>
#define BEAT 300 // define time for the tone.
#define PINNO 12
int led = 13;
void setup() { // setup code to run once:
pinMode(led, OUTPUT);
}
void loop() { // main code here, to run repeatedly:
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,262,BEAT); // C (do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,392,BEAT); // G(so)
delay(BEAT); tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
delay(1000); // Wait for 1 second
digitalWrite(led,HIGH); //Make No. 11pin output HIGH = 5V
delay(500); // Watering time
digitalWrite(led,LOW); //Make No.11 pin output LOW = 0V
//Shutdown Shut down program to save battery using by watchdogtimer 24h standby mode
int var = 0;
while(var < 10800){
delayWDT(9); // 9seconds of shutdown
var++; var++; // 10800times repeat =24h }
}
void delayWDT(unsigned long t) { // delay excute while using powerdown mode
delayWDT_setup(t); // watchdog timer setting
ADCSRA &= ~(1 << ADEN); // ADEN bit clear and stop ADC
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Powerdow mode
sleep_enable();
sleep_mode(); // sleep mode
sleep_disable(); // WatchDog Timer times up and start working agian again
ADCSRA |= (1 << ADEN); // turn on the ADC
}
void delayWDT_setup(unsigned int ii) { // setting uupup timer
// 0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
// 6=1sec, 7=2sec, 8=4sec, 9=8sec
byte bb;
if (ii > 9 ){ {
// get rid of stragestrange numbers
ii = 9;
}
bb =ii & 7;
if (ii > 7){ {
bb |= (1 << 5);
}
bb |= ( 1 << WDCE );
MCUSR &= ~(1 << WDRF); // MCU Status Reg. Watchdog Reset Flag ->0
// start timed sequence
WDTCSR |= (1 << WDCE) | (1<<WDE); // allow to edit watchdog(watchdog
// set new watchdog timeout value
WDTCSR = bb; //
WDTCSR |= _BV(WDIE);
}
ISR(WDT_vect) { // the work after time up, WDT
// wdt_cycle++;
}
I am making an automated watering system with Arduino
enter image description here Here is the code what I'm applying to Arduino. Code seems alright and, wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program, it doesn't run like i coded. After I applied this code to Arduino, water pump is just keep running forever. Can anyone check up my code to make this run properly?enter image description here
/**automatated watering program **/
#include <avr/sleep.h>
#include <avr/wdt.h>
#define BEAT 300 // define time for the tone.
#define PINNO 12
int led = 13;
void setup() { // setup code to run once:
pinMode(led, OUTPUT);
}
void loop() { // main code here, to run repeatedly:
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,262,BEAT); // C (do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,392,BEAT); // G(so)
delay(BEAT); tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
delay(1000); // Wait for 1 second
digitalWrite(led,HIGH); //Make No. 11pin output HIGH = 5V
delay(500); // Watering time
digitalWrite(led,LOW); //Make No.11 pin output LOW = 0V
//Shutdown program to save battery using by watchdogtimer 24h standby mode
int var = 0;
while(var < 10800){
delayWDT(9); // 9seconds of shutdown
var++; // 10800times repeat =24h }
}
void delayWDT(unsigned long t) { // delay excute while using powerdown mode
delayWDT_setup(t); // watchdog timer setting
ADCSRA &= ~(1 << ADEN); // ADEN bit clear and stop ADC
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Powerdow mode
sleep_enable();
sleep_mode(); // sleep mode
sleep_disable(); // WatchDog Timer times up and start working agian
ADCSRA |= (1 << ADEN); // turn on the ADC
}
void delayWDT_setup(unsigned int ii) { // setting uup timer
// 0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
// 6=1sec, 7=2sec, 8=4sec, 9=8sec
byte bb;
if (ii > 9 ){ // get rid of strage numbers
ii = 9;
}
bb =ii & 7;
if (ii > 7){ bb |= (1 << 5);
}
bb |= ( 1 << WDCE );
MCUSR &= ~(1 << WDRF); // MCU Status Reg. Watchdog Reset Flag ->0
// start timed sequence
WDTCSR |= (1 << WDCE) | (1<<WDE); // allow to edit watchdog(
// set new watchdog timeout value
WDTCSR = bb; //
WDTCSR |= _BV(WDIE);
}
ISR(WDT_vect) { // the work after time up, WDT
// wdt_cycle++;
}
Making an automated watering system with Arduino
Here is the code that I'm using with Arduino. The code seems alright and the wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program doesn't run like I coded. After I uploaded this code to Arduino, the water pump just keeps running forever. Can anyone check up my code to make this run properly?
/**automated watering program **/
#include <avr/sleep.h>
#include <avr/wdt.h>
#define BEAT 300 // define time for the tone.
#define PINNO 12
int led = 13;
void setup() { // setup code to run once:
pinMode(led, OUTPUT);
}
void loop() { // main code here, to run repeatedly:
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,262,BEAT); // C (do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,392,BEAT); // G(so)
delay(BEAT); tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,262,BEAT); // C(do)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
tone(PINNO,330,BEAT); // E(mi)
delay(BEAT);
tone(PINNO,294,BEAT); // D(re)
delay(BEAT);
delay(1000); // Wait for 1 second
digitalWrite(led,HIGH); //Make No. 11pin output HIGH = 5V
delay(500); // Watering time
digitalWrite(led,LOW); //Make No.11 pin output LOW = 0V
// Shut down program to save battery using by watchdogtimer 24h standby mode
int var = 0;
while(var < 10800){
delayWDT(9); // 9seconds of shutdown
var++; // 10800times repeat =24h }
}
void delayWDT(unsigned long t) { // delay excute while using powerdown mode
delayWDT_setup(t); // watchdog timer setting
ADCSRA &= ~(1 << ADEN); // ADEN bit clear and stop ADC
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Powerdow mode
sleep_enable();
sleep_mode(); // sleep mode
sleep_disable(); // WatchDog Timer times up and start working again
ADCSRA |= (1 << ADEN); // turn on the ADC
}
void delayWDT_setup(unsigned int ii) { // setting up timer
// 0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
// 6=1sec, 7=2sec, 8=4sec, 9=8sec
byte bb;
if (ii > 9 ) {
// get rid of strange numbers
ii = 9;
}
bb =ii & 7;
if (ii > 7) {
bb |= (1 << 5);
}
bb |= ( 1 << WDCE );
MCUSR &= ~(1 << WDRF); // MCU Status Reg. Watchdog Reset Flag ->0
// start timed sequence
WDTCSR |= (1 << WDCE) | (1<<WDE); // allow to edit watchdog
// set new watchdog timeout value
WDTCSR = bb;
WDTCSR |= _BV(WDIE);
}
ISR(WDT_vect) { // the work after time up, WDT
// wdt_cycle++;
}
Hereenter image description here Here is the code what I'm applying to Arduino. Code seems alright and, wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program, it doesn't run like i coded. After I applied this code to Arduino, water pump is just keep running forever. Can anyone check up my code to make this run properly? enter image description here
Here is the code what I'm applying to Arduino. Code seems alright and, wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program, it doesn't run like i coded. After I applied this code to Arduino, water pump is just keep running forever. Can anyone check up my code to make this run properly? enter image description here
enter image description here Here is the code what I'm applying to Arduino. Code seems alright and, wiring on the Arduino seems okay as well, but I don't know where to place a speaker on the Arduino. The biggest problem is that the program, it doesn't run like i coded. After I applied this code to Arduino, water pump is just keep running forever. Can anyone check up my code to make this run properly? enter image description here