Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Initializing Array - expected primary expression before "{" token on: November 24, 2013, 03:14:25 pm
@ mrburnette

Wet Fish.....engaged.

@ PaulS

This is what you were laking about, right?

Code:
[sunMatrix[1][0][Sunrise_Hr] = 0;
sunMatrix[1][0][Sunrise_Min] = 0;
sunMatrix[1][0][Sunset_Hr] = RiseHour;
sunMatrix[1][0][Sunset_Min] = RiseMin + 2;
sunMatrix[1][0][SunLevel] = 0;
sunMatrix[1][1][Sunrise_Hr] = RiseHour;
sunMatrix[1][1][Sunrise_Min] = RiseMin + 10;
sunMatrix[1][1][Sunset_Hr] = RiseHour + 12;
sunMatrix[1][1][Sunset_Min] = RiseMin + 7;
sunMatrix[1][1][SunLevel] = RBlue_max;
sunMatrix[1][2][Sunrise_Hr] = RiseHour + 12;
sunMatrix[1][2][Sunrise_Min] = RiseMin + 12;
sunMatrix[1][2][Sunset_Hr] = 24;
sunMatrix[1][2][Sunset_Min] = 0;
sunMatrix[1][2][SunLevel] = 0

sunMatrix[0][0][Sunrise_Hr] = 0;
sunMatrix[0][0][Sunrise_Min] = 0;
sunMatrix[0][0][Sunset_Hr] = RiseHour;
sunMatrix[0][0][Sunset_Min] = RiseMin + 2;
sunMatrix[0][0][SunLevel] = 0;
sunMatrix[0][1][Sunrise_Hr] = RiseHour;
sunMatrix[0][1][Sunrise_Min] = RiseMin + 10;
sunMatrix[0][1][Sunset_Hr] = RiseHour + 12;
sunMatrix[0][1][Sunset_Min] = RiseMin + 7;
sunMatrix[0][1][SunLevel] = RBlue_max;
sunMatrix[0][2][Sunrise_Hr] = RiseHour + 12;
sunMatrix[0][2][Sunrise_Min] = RiseMin + 12;
sunMatrix[0][2][Sunset_Hr] = 24;
sunMatrix[0][2][Sunset_Min] = 0;
sunMatrix[0][2][SunLevel] = 0;

it will be tedious....but effective
2  Using Arduino / Programming Questions / Re: Initializing Array - expected primary expression before "{" token on: November 24, 2013, 10:15:56 am
I see....somewhat.

Since,
sunMatrix[CHANNELS][MAXPERIODS][5]=
{
 {

Gives me the same compilation error

Do I have to initialise like this?

int sunMatrix[CHANNELS][MAXPERIODS][5]=
{
 {

Or, If you could please point me to a reference where I can learn the correct way to initialize this array. The Reference center here did not offer much help for what I'm trying to do.

Thanks AWOL!
3  Using Arduino / Programming Questions / Re: Initializing Array - expected primary expression before "{" token on: November 24, 2013, 09:43:34 am
Thanks for the quick reply AWOL.

We're getting to where I'm going wrong. I am guessing I do not know how to declare it as I thought that that's what I was doing with this line.

int sunMatrix[CHANNELS][MAXPERIODS][5];
4  Using Arduino / Programming Questions / Initializing Array - expected primary expression before "{" token on: November 24, 2013, 09:20:43 am
Hello everyone,

I would like to initialize an array from a void function, and I am having a bit of difficultly achieving that.

Here is the code as I have it:
Code:
int RiseHour = 0;
int RiseMin = 0;
int change_start_time = 0;

const int CHANNELS = 8;
const int MAXPERIODS = 3;

const int Sunrise_Hr = 0;
const int Sunrise_Min = 1;
const int Sunset_Hr = 2;
const int Sunset_Min = 3;
const int SunLevel = 4;

int sunMatrix[CHANNELS][MAXPERIODS][5];
int sunValue[CHANNELS] = {0, 0, 0, 0, 0, 0, 0, 0};


void UpdateMatrix(){

sunMatrix =
{
{
{0, 0, RiseHour+2, RiseMin, 0},
{RiseHour+2, RiseMin+14, RiseHour+8, RiseMin, White_max},               ////Wht_Ch1
{RiseHour+8, RiseMin+12, 24, 0, 0}
},{
{0, 0, RiseHour, RiseMin+2, 0},
{RiseHour, RiseMin+10, RiseHour+12, RiseMin+7, RBlue_max},             ////RBlue_Ch1
{RiseHour+12, RiseMin+12, 24, 0, 0}
},{
{0, 0, RiseHour, RiseMin+8, 0},
{RiseHour, RiseMin+14, RiseHour+12, RiseMin+2, Blue_max},               ////Blue_Ch1
{RiseHour+12, RiseMin+8, 24, 0, 0}
},{
  {0, 0, RiseHour+2, RiseMin+2, 0},
{RiseHour+2, RiseMin+14, RiseHour+8, RiseMin+2, White_max},             ////Wht_Ch2
{RiseHour+8, RiseHour+13, 24, 0, 0}
},{
{0, 0, RiseHour+2, RiseMin+3, 0},
{RiseHour+2, RiseMin+14, RiseHour+8, 20, White_max},             ////Wht_Ch3
{RiseHour+8, RiseMin+14, 24, 0, 0}
},{
{0, 0, RiseHour, RiseMin+3, 0},
{RiseHour, RiseMin+10, RiseHour+12, RiseMin+9, RBlue_max},              ////RBlue_Ch2
{RiseHour+12, RiseMin+13, 24, 0, 0}
},{
{0, 0, RiseHour, RiseMin+10, 0},
{RiseHour, RiseMin+14, RiseHour+12, RiseMin+5, Blue_max},               ////Blue_Ch2
{RiseHour+12, RiseMin+9, 24, 0, 0}
},{
{0, 0, RiseHour, RiseMin, 2},
{RiseHour, RiseMin+3, RiseHour+12, RiseMin+13, UV_max},              ////UV_Ch1
{RiseHour+12, RiseMin+14, 24, 0, 2}
}
}

I am receiving a -expected a primary expression before "{" token- error during compilation on this line

sunMatrix =
{

I am hoping one of you great minds can direct me as to where I might be going wrong??

Thanks for your time!
5  Using Arduino / General Electronics / external power on an Atlas Scientific pH stamp on: October 26, 2013, 01:49:29 am
Hello all,

I would like to use an external 5v source to power the pictured pH stamp from Atlas Scientific.

Can I do that? or, is it necessary to run the 5v and GND from the Arduino?

https://www.atlas-scientific.com/_images/_gallery/embedded/26-ph-3-circuit.jpg

Thanks for any help!
6  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 12:20:09 pm
Quote
something like:

outletState = digitalRead(OUTLETS[on]);
If you call that in a loop, outletState will contain the state of the last pin in the array. You need an array of states, too.

Code:
outletState[on] = digitalRead(OUTLETS[on]);

Thank you both so much! It's starting to sink in.

I've been making some progress, and have it producing the results I would like. However, the code is not that efficient. Before you clued me in on needing an outletState array as well I wrote a digitalRead of every index = to outletState

Example:

outletState = digitalRead(OUTLETS[0]);
if (outletState == HIGH){
....
else if (outletState == LOW){
....

and then to the next if & else if

outletState = digitalRead(OUTLETS[1]);

and so on through the index.

Now I can try slimming it down a bit.

Thanks to you both!!
7  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 11:26:03 am
OUTLETS
  • has the value A0.
That is never ever going to be equal to one.

Quote
I guess I don't understand how it is discarding the result.
OK, put it this way - where do you think the value returned by the digitalRead is going to end up?

I think I'm starting to see. I need to store or direct the read?

something like:

outletState = digitalRead(OUTLETS[on]);

where outletState is where the digitalRead ends up?
8  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 11:07:11 am
Code:
if (OUTLETS[0] == HIGH){
Does it seem likely that A0 has the same value as HIGH (1)?

I couldn't be sure without completely guessing.

When you say HIGH(1) are you referring to HIGH(1) and LOW would then be LOW(0)?
9  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 11:01:47 am
Read the pin and discard the result.
Not good.

Ah. Ok. I guess I don't understand how it is discarding the result.

Should I remove that for loop, and digitalRead each?

I was trying to be efficient
10  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 10:57:48 am
I have changed it back to 8. I started to confuse myself when I was trying to manipulate the code to get the desired result.

Besides that error the arrays seem proper??

Perhaps I should be looking in my status function with a problem in the if & else if statements.
11  Using Arduino / Programming Questions / Re: Learning Arrays Question on: September 22, 2013, 10:40:42 am
No. I didn't mean to leave it off.

I had originally set it to 8, however when it didn't work the first time I had changed it to 7. My thinking was that the first index was zero[0].
12  Using Arduino / Programming Questions / Learning Arrays Question on: September 22, 2013, 10:35:34 am

Hi everyone.

I am trying to learn how to use and incorporate arrays into my code, but I don't think I have a 100% handle on it yet.

The following is an array that I have been trying to write, but I am not getting results that I would suspect.

I set up the array pin numbers

in void set up I set all pins in array to OUTPUTS
and use a digitalWrite to set all pins HIGH

I then have a function to load the Outlet_Screen and call the Outlet_Status function.

The Outlet_Status is used to digitalRead the array, and then draw a fillCircle either green or red dependent upon whether the pin is HIGH or LOW.

The results that I would expect is when I navigate to the Outlet Screen all fillCircles  would be drawn green since they are all set HIGH in void setup().

However, I am getting no results at all. No fillCircles are being drawn and screen remains blank.
I have tried it various ways, but have not yet figured out my issue.

Any help locating where I have gone wrong would be appreciated. Thank you!

Code:

int OUTLETS[8] ={A8,A9,A10,A11,A12,A13,A14,A15};                    //set the pins in the array

void setup(){
for (int on=0; on<7; on++) pinMode(OUTLETS[on], OUTPUT);        //array sets outlet box pins as outputs
 
for (int on=0; on<7; on++) digitalWrite(OUTLETS[on], HIGH);       //array sets outlet pins HIGH/ON
}

 
void Outlet_Screen(){
     
   Outlet_Status();                                                         
   
   myGLCD.loadBitmap(0,0,240,252, "OUTLETS.raw");       //loads outlet screen
   
   myGLCD.setColor(0,0,255);
   myGLCD.drawRoundRect(8,309,231,255);                      //Draw Clock Button   
 }


 void Outlet_Status(){                      //Function indicates power status with Green or Red light
   if (outlet_screen == true){
   for (int on=0; on<7; on++) digitalRead(OUTLETS[on]);
   
   if (OUTLETS[0] == HIGH){
   myGLCD.setColor(0,255,0);           //outlets are default "ON" 
   myGLCD.fillCircle(101,51,11);       //Green Fill Circles will indicate this
   }
   else if (OUTLETS[0] == LOW){
   myGLCD.setColor(255,0,0);           //outlet "OFF" 
   myGLCD.fillCircle(101,51,11);       //Red Fill Circle will indicate this
   }
   
   if (OUTLETS[1] == HIGH){
   myGLCD.setColor(0,255,0);
   myGLCD.fillCircle(101,94,11);
   }
   else if (OUTLETS[1] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(101,94,11);
   }

   if (OUTLETS[2] == HIGH){
   myGLCD.setColor(0,255,0);
   myGLCD.fillCircle(101,137,11);
   }   
   else if (OUTLETS[2] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(101,137,11);
   }
   
   if (OUTLETS[3] == HIGH){
   myGLCD.setColor(0,255,0);
   myGLCD.fillCircle(101,181,11);
   }
   else if (OUTLETS[3] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(101,181,11);
   }
 
   if (OUTLETS[4] == HIGH){
   myGLCD.setColor(0,255,0); 
   myGLCD.fillCircle(222,51,11);
   }
   else if (OUTLETS[4] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(222,51,11);
   }
 
   if (OUTLETS[5] == HIGH){
   myGLCD.setColor(0,255,0);   
   myGLCD.fillCircle(222,95,11);
   }
   else if (OUTLETS[5] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(222,95,11);
   }
   
   if (OUTLETS[6] == HIGH){
   myGLCD.setColor(0,255,0);   
   myGLCD.fillCircle(222,137,11);
   }
   else if (OUTLETS[6] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(222,137,11);
   }
   if (OUTLETS[7] == HIGH){
   myGLCD.setColor(0,255,0);   
   myGLCD.fillCircle(222,181,11);
   }
   else if (OUTLETS[7] == LOW){
   myGLCD.setColor(255,0,0);
   myGLCD.fillCircle(222,181,11);
   } 
 }
}


void loop(){


      if (settings_screen == true){
       
        if((y<=166) && (y>=121)){
        if((x<=222) &&(x>=177)){
          waitForIt(177,121,222,166);
          x=0;
          y=0;
          settings_screen = false;
          outlet_screen = true;
          Outlet_Screen();
        }
       }
      }
13  Using Arduino / Storage / Data Logger to SD to LCD on: July 04, 2013, 10:42:00 pm
I need a push in the right direction...or maybe a brick upside the head.

I am looking to graph temperature data from an SD card onto a 3.2 TFT LCD. I would like to know what I should be researching/studying to make this happen?
All my searches lead me to Processing and graphing to a computer via Serial port, but that's not exactly what I want.

I would like to graph the data directly to this screen


I would like it to default display current 7 days (in Green = 1), and then if I need I can call 7 days at a time each week a different color...Button numbers 1 through 4.

Saving the data with the data logger to the SD card should be simple enough for me to handle.

I would like to know how I should structure this code?

Is there a simple code to set up the graph x & y coordinates?

If so, I think I can then write a function to print the data to the LCD and use drawline from the UTFT library.
I also want it to overwrite data older than the 28 days.

Thanks for any help! I just need a good idea of how I should structure the code.
14  Using Arduino / Programming Questions / What does this mean? on: June 19, 2013, 11:48:20 am
if (home_screen == true){
  if (Seconds % 4 == 0){
    Print_Temp()

I am unsure what % is in the programming language. This bit of code solved a problem I was having, but I would like to understand why it did.

15  Using Arduino / Project Guidance / Re: TFT - Sensor conflict on: May 23, 2013, 10:55:21 pm
See....here's where my lack of experience hinders me as I don't know what section of code would be advisable to post, and I felt that posting the entire code thus far would be too much.

But, here it is...I don't have any delays written into my code as of yet. I had to cut quite a bit in order to maintain the maximum allowed length, but hopefully left all the pertinent code.

Code:
//*******Included Libraries*******//


#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

//********    Declare Touch/LCD/RTC    **********
UTFTtf  myGLCD(ITDB32S, 38, 39, 40, 41);
ITDB02_Touch  myTouch(46,45,44,43,42);
RTC_DS1307 RTC;
 

//*******   Declare 1-Wire for TEMP sensors  ********
#define ONE_WIRE_BUS 6
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature tempsensors(&oneWire);

float Tank_TempC;
float Tank_TempF;


   
    

//*******************************************      $Setup      ********************************[#SETUP]


void setup(){


  Wire.begin();
  RTC.begin();                                        //Initiate Real Time Clock
  


  tempsensors.begin();                                     //Begin Dallas 1-Wire Temperature
  pinMode(6, OUTPUT);
  if(!oneWire.search(tank_thermometer));
  
 // RTC.adjust(DateTime(__DATE__, __TIME__));            //Sets clock to current upload time
  
  Serial.begin(9600);
  boolean home_screen = true;
  Home_Screen();
}


/////////********************************** FUNCTIONS *******************************************//////////

 void Read_Temp(){
 
  tempsensors.requestTemperatures();
  Tank_TempC = tempsensors.getTempCByIndex(0);
  Tank_TempF = (((Tank_TempC * 9.0) / (5.0)) + 32.0);
  
}

 void Print_Temp(){
        if(home_screen == true){
      
       Read_Temp();
    
       myGLCD.setColor(0,255,255);
       myGLCD.setFont(Sinclair_M);
      
       myGLCD.print("F", 207, 21);
       myGLCD.printNumF(Tank_TempF, 1, 132, 21);
        }  
}


 ////////############ Home_Screen ###########///////
 /////Draws and adds functions of the homescreen////

 
 void Home_Screen(){
  
 //***** Draw Home_Screen *****
  myGLCD.loadBitmap(0,1,240,252, "HOMESC~1.raw");   //Homescreen Logo
  myGLCD.setColor(0,255,255);
  myGLCD.setFont(Sinclair_M);
  myGLCD.print("TEMP.:", 20, 21);
  myGLCD.print("pH  :", 35, 74);
  myGLCD.setColor(0,0,255);                         //sets button frame color to blue
  myGLCD.drawRoundRect(8,309,231,255);              //Draws Frame for clock read
  myGLCD.drawRoundRect(8,8,231,46);                 //Draws frame for temperature read
  myGLCD.drawRoundRect(8,62,231,100);               //Draws frame for pH read
  myGLCD.setColor(0,0,0);
  myGLCD.drawRoundRect(8,101,231,252);
  
 }


//################### Touch Indication #################//
///## Indicates a button touch by drawing a RED frame ##//


void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255,0,0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);


    while (myTouch.dataAvailable()){                            
      myTouch.read();
      x = myTouch.getX();
      y = myTouch.getY();
    }


  if ((home_screen == true) && (y <= 252) && (y >= 103)){
  myGLCD.setColor(0,0,0);                             //returns menu frame to black

  }
  else {
    myGLCD.setColor(0,0,255);                         //returns all other menu frames to blue
  }
}


//#################################### MAIN LOOP#######################################################//


void loop(){
    
//This code segment reads the current touch screen data (position pressed by the user) and stores the
//x value and the y value.

  if (myTouch.dataAvailable()){          //Get Curent Screen Data
    myTouch.read();
    x = myTouch.getX();
    y = myTouch.getY();
    Serial.print(x);
    Serial.print(" / ");
    Serial.println(y);
  }


//######################## CLOCK ##############################//

// This segment of code starts and draws Clock for all screens

  DateTime now = RTC.now();             //sets Datetime "now" to the current time
  Hours = now.hour();                 //Sets time varibles to Current RTC time
  Minutes = now.minute();
  Seconds = now.second();
  Day = now.day();
  Month = now.month();
  Year = now.year();
  Weekday = now.dayOfWeek();
  
  Draw_Clock(24, 252);
  

  //################ Navigation Touch Code ##############//
  //This code segment is for navigation from screen to screen
  
  if (home_screen == true){            //*****home screen begin*****
     Print_Temp();                          //call to Print_Temps function
    
        if ((y >= 101) && (y <= 250)){         //menu button touch                              
         if ((x>=8) && (x<=231)){
          waitForIt(8, 101, 231, 250);
          x = 0;
          y = 0;

         Screen_select_false();
         menu_screen = true;
         Menu_Screen();
        }
      }
  
           if((y>=8) &&(y<=46)){               //Tenperature button touch
            if ((x>=8) && (x<=231)){
            waitForIt(8,8,231,46);
            x = 0;
            y = 0;
            
            Screen_select_false();
            temp_screen = true;
            TempHome_Screen();
            }
         }
            
        
            if((y>=62) &&(y<=100)){          //pH screen touch button from Home_Screen
            if ((x>=8) && (x<=231)){
            waitForIt(8,62,231,100);
            x = 0;
            y = 0;
            
            Screen_select_false();
            ph_screen = true;
            PH_Screen();
            }
          }                                   //******End Home Screen Touch********
        }    

          
 
 
 //************menu screen touch begin**************      

           if(home_screen == false){
           if (menu_screen == true){
            
        if ((y >= 179) && (y <= 243)){       //home return touch button
          if((x>=8) && (x<=93)){            
          waitForIt(29, 179, 93, 243);
          x = 0;
          y = 0;

         Screen_select_false();
         home_screen = true;
         Home_Screen();
     }
      
        }else if((y>=7) && (y<=71)){         //LED screen touch button
          if((x>=28) && (x<=92)){
            waitForIt(28,7,92,71);
            x=0;
            y=0;

           Screen_select_false();
           ledhome_screen = true;
           LEDhome_Screen();  
     }
        
          if((y>=7) && (y<=71)){         //TEMP screen touch button
          if((x>=143) && (x<=208)){
            waitForIt(143,7,208,71);
            x=0;
            y=0;

           Screen_select_false();
           temp_screen = true;
           TempHome_Screen();        
     }
    }
        
        }else if((y>=91) && (y<=154)){         //PH screen touch button
          if((x>=144) && (x<=208)){
            waitForIt(144,91,208,154);
            x=0;
            y=0;

           Screen_select_false();
           ph_screen = true;
           PH_Screen();
       }
      }
     }
    

 //################## Home & Menu Return Code #########################################//    
          
           if(home_screen == false && menu_screen == false){
           if(ledchannel_screen == false && ledevents_screen == false){
            
           if ((y<=250) && (y>=214)){               //home screen return from pH/Temp/LED
           if((x>=161) && (x<=196)){
           waitForIt(161,250,196,214);
           x=0;
           y=0;
          
          Screen_select_false();
          home_screen = true;        
          Home_Screen();
        }
       }
            
           if ((y<=250) && (y>=216)){              //menu screen return from pH/Temp/LED screens
           if((x>=203) && (x<=238)){
           waitForIt(203,250,238,216);
           x=0;
           y=0;
          
          Screen_select_false();
          menu_screen = true;
          Menu_Screen();
        }
      }
    }
  
//######################################################################################


//********************* LED Touch Begin ********************//        
          
          if (ledhome_screen == true){

           if((y<=206) && (y>=29)){
           if((x<=229) && (x>=138)){
             waitForIt(139,33,230,210);
             x=0;
             y=0;
             ledhome_screen = false;
             ledchannel_screen = true;
             LEDchannel_Screen();                   ///Color Channels Popup

           }
          }
          
       }
       else if (ledhome_screen == false){     //**********return to LEDmaster screen******
                    
           if((y<=213) && (y>=182)){
           if((x<=31) && (x>=2)){
             waitForIt(2,182,31,213);
             x=0;
             y=0;
            
             Screen_select_false();
             ledhome_screen = true;
             LEDhome_Screen();              //***********End Return to LEDmaster Screen***
             Print_Led_Brightness();  
           }
          }
         }
        

Thanks for your time.
Pages: [1] 2 3