aquaponic light and pump loop help


hello guys , in advance,

i in process of setting small aquaponic system. have arduino nano , sainsmart ssr board, understand schematics hook board however, haveing trouble setting arduino like. need arduino set pin high 2 minutes go low 3 3 times go low 45 minutes. kicker while doing need run analog read on photocell , turn pin high or low based on photocell reading. did use blink without delay , modified it. added second interval pin go low different amount of time high. got frusterated because wouldnot work. decided post on here direction or if im lucky code can modify ;)

thanks again guys

this far got , notice need syntax too







const int pumppin =  13;     
int pumpstate = low;           
long previousmillis = 0;       
long interval1 = 12000;
long interval2 = 18000;
long interval3 = 27000;

void setup() {

  pinmode(pumppin, output);     
}

void loop()

  {
  unsigned long currentmillis = millis();

  if(currentmillis - previousmillis > interval1) {
    previousmillis = currentmillis;   

   
    if (pumpstate == low)
      pumpstate = high;
    else
      pumpstate = low;
    digitalwrite(pumppin, pumpstate);
  }

 
 
{
   
  unsigned long currentmillis = millis();

  if(currentmillis - previousmillis > interval2) {
    previousmillis = currentmillis;   

   
    if (pumpstate==low)
      pumpstate = high;
    else
      pumpstate = low;
    digitalwrite(pumppin, pumpstate);
  }

quote
you notice need syntax too


you need understand use of  {   and } brackets define groups of statements go together.

this:
code: [select]
  unsigned long currentmillis = millis();

  if(currentmillis - previousmillis > interval1) {
    previousmillis = currentmillis;   

   
    if (pumpstate == low)
      pumpstate = high;
    else
      pumpstate = low;                       // these 2 statements not grouped together
    digitalwrite(pumppin, pumpstate);
  }


does not work because not controlling statements go together...

try kind of structure:

code: [select]

  unsigned long currentmillis = millis();

  if(currentmillis - previousmillis > interval1)

{  // if interval has ended 
    previousmillis = currentmillis;   

   
    if (pumpstate == low)
   {
      pumpstate = high; 
     digitalwrite(pumppin, pumpstate);   // maybe trying ??
   }

  } // end of if interval has ended 


maybe @ example of starting program structure:
http://arduino-info.wikispaces.com/yourduinostarter_sketchtemplate


Arduino Forum > Using Arduino > Project Guidance > aquaponic light and pump loop help


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support