cosinehigh
Member
Hello, I have made this post before but I guess it was deleted because I was not actively updating it? I will try to make a better post this time:
parts:
Arduino Uno (or any of these: http://arduino.cc/en/Main/Hardware)
Arduino relay: http://www.google.com/search?hl=en&tbm=shop&q=arduino+relay&oq=arduino+relay&aq=f&aqi=g3&aql=&gs_l=products-cc.3..0l3.6838.8854.0.9190.13.6.0.7.7.0.63.322.6.6.0...0.0.
USB Cable for the arduino
Computer/Laptop: (to program the arduino)
12V to 5V DC step down converter: http://www.google.com/search?hl=en&tbm=shop&q=arduino+relay&oq=arduino+relay&aq=f&aqi=g3&aql=&gs_l=products-cc.3..0l3.6838.8854.0.9190.13.6.0.7.7.0.63.322.6.6.0...0.0.#hl=en&tbm=shop&sclient=psy-ab&q=12v+5v+step+down+dc&oq=12v+5v+step+down+dc&aq=f&aqi=&aql=&gs_l=serp.3...108401.108401.0.108699.1.1.0.0.0.0.64.64.1.1.0...0.0.1DrI6DfB_0U&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=c98cb5f7c30965f0&biw=1159&bih=791
12V trickle charger: used to power the system even when power is off.
12v 8mAh battery
12v solenoid valve: http://stores.ebay.com/valves4projects
1. Download and install the arduino software onto your computer: http://arduino.cc/en/Main/Software
2. Connect the 12v trickle charger to the 12v battery. The battery will supply power to the 12v to 5v DC DC converter and also supply power to the 12v solenoid valves.
set up diagram:
3. Program your arduino using the code below. the // means that it is a comment and will not be used by the program.
5. Select the correct board, and port to upload under Arduino> Tools
You may need to change the output pins, since your arduino may be different than mines. but it is very basic and very easy to program and use. Please ask any questions. i promise to respond.
parts:
Arduino Uno (or any of these: http://arduino.cc/en/Main/Hardware)
Arduino relay: http://www.google.com/search?hl=en&tbm=shop&q=arduino+relay&oq=arduino+relay&aq=f&aqi=g3&aql=&gs_l=products-cc.3..0l3.6838.8854.0.9190.13.6.0.7.7.0.63.322.6.6.0...0.0.
USB Cable for the arduino
Computer/Laptop: (to program the arduino)
12V to 5V DC step down converter: http://www.google.com/search?hl=en&tbm=shop&q=arduino+relay&oq=arduino+relay&aq=f&aqi=g3&aql=&gs_l=products-cc.3..0l3.6838.8854.0.9190.13.6.0.7.7.0.63.322.6.6.0...0.0.#hl=en&tbm=shop&sclient=psy-ab&q=12v+5v+step+down+dc&oq=12v+5v+step+down+dc&aq=f&aqi=&aql=&gs_l=serp.3...108401.108401.0.108699.1.1.0.0.0.0.64.64.1.1.0...0.0.1DrI6DfB_0U&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=c98cb5f7c30965f0&biw=1159&bih=791
12V trickle charger: used to power the system even when power is off.
12v 8mAh battery
12v solenoid valve: http://stores.ebay.com/valves4projects
1. Download and install the arduino software onto your computer: http://arduino.cc/en/Main/Software
2. Connect the 12v trickle charger to the 12v battery. The battery will supply power to the 12v to 5v DC DC converter and also supply power to the 12v solenoid valves.
set up diagram:
3. Program your arduino using the code below. the // means that it is a comment and will not be used by the program.
Code:
unsigned char relayPin[12] = {4,5,6,7};//Remainining pins: (22,23,24,25,26,27,28,29}; // Define the led's pin
//initializes the function: Zone
void Zone(unsigned long on, unsigned long off, int i);
int mode[4]={LOW,LOW,LOW,LOW}; //Initilizes mode array to LOW (OFF) Mode
unsigned long previousMillis[5]={0,0,0,0,0}; //initilizes previousMillis array
//Conversions
unsigned long Sec = 1000UL;
unsigned long Min = 60000UL;
//unsigned long Hour=60*Min;
//unsigned long daytime=43200000UL;
void setup()
{
//Initilizes the Pins as OUTPUT going through the for loop.
int i;
for(i = 0; i < 4; i++)
{
pinMode(relayPin[i],OUTPUT);
digitalWrite(relayPin[i],mode[i]);
}
}
void loop(){
Zone(3*Min,15*Min,0);
Zone(6000UL,900000UL,1);
Zone(4000UL,900000UL,2);
}
/*
Zone:
Recieves: On time, Off time, and Pin Number(0-4)
Note: millis() function calls time since arduino has been on, in milliseconds (ms)
psuedocode:
if (millis) - previlousMillis[i] is greater than (Off Time) and mode is equal to LOW
then set previousMillis[i] to (millis), set pin mode to HIGH(ON),
then it does it again for the ON time
*/
void Zone(unsigned long on, unsigned long off, int i){
if (millis() - previousMillis[i]>= off && mode[i]==LOW){
previousMillis[i]=millis();
mode[i]=HIGH;
digitalWrite(relayPin[i],mode[i]);
}
if (millis()-previousMillis[i]>= on && mode[i] == HIGH){
previousMillis[i]=millis();
mode[i]=LOW;
digitalWrite(relayPin[i],mode[i]);
}
}
You may need to change the output pins, since your arduino may be different than mines. but it is very basic and very easy to program and use. Please ask any questions. i promise to respond.