Show Posts
Pages: 1 2 3 [4] 5 6 ... 25
46  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 02:12:18 pm
I count 1 pump and 4 valves.

(1) Do you want the pump to turn on when any of the four moisture sensors are dry?
(2) Do you want the pump to turn off when any of the four moisture sensors are wet?

It looks to me like your code is doing both (1) and (2).

Cheers,
John
47  Using Arduino / Programming Questions / Re: moisture sensors on: February 10, 2013, 10:54:59 pm
Not sure what you are thinking here but am pretty sure it's not right smiley
Code:
const int PROBE = A0-A4; // Analog pin 0-3
...

void setup() {
   pinMode(PROBE,INPUT);
   ...
}

Maybe you want
Code:
const int PROBE1=A0, PROBE2=A1, PROBE3=A2, PROBE4=A3;

pinMode( PROBE1,  INPUT);
pinMode( PROBE2,  INPUT);
... etc

But, I would recommend getting ONE of them working before writing all that non-working code for FOUR...

And then you can learn about arrays to expand for the other three smiley

Cheers,
John
48  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 05:21:29 pm
Let's say you are able to get it into a string like "68.00, 1, 0, 1, 1, 66.00, 0, 0, 5, 23, 20, 0".  What are you going to do with it then?



49  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 01:47:55 pm
In the below string you already have the start of data marker colon : and end of data marker comma ,.

There will also be these colons and commas that need to be "bypassed"  though:
Code:
Cache-Control: no-store, no-cache, must-revalidate
50  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 01:45:09 pm
For such a simple parsing requirement I'd just process the input stream one character at a time, looking for the opening brace ('{').

Once found, process each subsequent character, probably in a switch statement:

If it's a decimal digit or a period, append to a buffer holding the current input field.
If it's a closing brace ('}'), the input line is complete. Save the content of the buffer (if any) and end the parsing.
If it's any other character, save the content of the buffer (if any) and reset the buffer ready for the next field.

I agree with this except it's a little bit harder, because he has nested curlies {,,,{,,,}}
51  Using Arduino / Programming Questions / Re: Passing a function another function on: February 10, 2013, 11:57:00 am
I worked your code into mine Johncc, and it is telling me
Code:
barbotV18:40: error: variable or field 'checkglass' declared void
barbotV18:40: error: 'drinkfunction' was not declared in this scope
How should I declare drinkfunction- what type of pointer is it?

Hmm, my code should translate directly into yours, with names of your choosing.  If you don't want to post your whole code, probably need to post at least your:

typedef
function prototype
declaration of drinkFunction
declaration of checkglass
code that calls checkglass

John
52  Using Arduino / Programming Questions / Re: Delay question on: February 10, 2013, 09:25:55 am
Where would you suggest I look for TimeAlarms library info?

Google?  smiley

TimeAlarms is included in the Time library:
Code:
http://playground.arduino.cc/Code/time

Unfortunately the playground does not include documentation for it though.  But see the example sketch--and the readme file in the library folder that you install.

And google.  http://www.lmgtfy.com/?q=arduino+timealarms

Cheers,
John
53  Using Arduino / Programming Questions / Re: Passing a function another function on: February 10, 2013, 08:52:18 am
@Jim_Socks

I seem to remember some quirkyness to Arduino typedefs, boiling down to requiring that certain functions must be "prototyped" .  Here is some working code that shows the technique you are looking for.  If you remove the "Arduino Quirk" prototype line, the compile will fail

Code:
typedef void (*drinkFun)(void);

void glasscheck( drinkFun fptr);  // Arduino quirk; must be prototyped

void glasscheck( drinkFun fptr){
    // ...
    fptr();
    // ...
}

void VodkaOnRocks(void) {
    Serial.println("Vodka On Rocks Fun");
}
void Margarita(void) {
    Serial.println("Margarita Fun");
}


void setup(){
   Serial.begin(19200);
   glasscheck( VodkaOnRocks);
   // or
   drinkFun rita=Margarita;
   glasscheck( rita);
}


void loop(){}

Cheers,
John

edit: renamed functions for domain
54  Using Arduino / Programming Questions / Re: Problem with setSyncProvider() [from Time Library] on: February 09, 2013, 02:51:08 pm
Is this part of the standard example that comes with 1.0.3?

P.S. I downloaded 1.0.3 and confirmed there is no Time library that "comes with" the IDE.  The most current/recommended Time library appears to be http://playground.arduino.cc/Code/Time which does not include the adjustDstEurope in it's example.  But it does require an additional library, "udpbytewise"

John
55  Using Arduino / Programming Questions / Re: Problem with setSyncProvider() [from Time Library] on: February 09, 2013, 01:47:13 pm
Hi purehunter,

I believe your problem is in adjustDstEurope(), it works if I remove the call from getNtpTime as so:
Code:
     unsigned long epoch = secsSince1900 - seventyYears ;  // removed + adjustDstEurope();

adjustDstEurope is calling time library functions including month() and day().  It would not suprise me if this is causing recursive calls to getNtpTime, which would explain why it "never returns" once you call setSyncProvider in setup.

Is this part of the standard example that comes with 1.0.3?

Cheers,
John
56  Using Arduino / Programming Questions / Re: Problem with setSyncProvider() [from Time Library] on: February 09, 2013, 11:37:54 am
Quote
So what is the "flawed fundamental assumption" that you think he is making?  Maybe I am making it too.
That setSyncProvider() needs to be called every time a sync is to occur, and that that is the only time the sync occurs.

Well, that's not an assumption I am making.  But I can't speak for purehunter...
57  Using Arduino / Programming Questions / Re: Help Understanding Code: processInput on: February 09, 2013, 11:00:38 am
I remember seeing this code when you posted it before because the variable name just cracks me up smiley

Code:
void processNumber (int x)
{

  switch (whichNumber)
  {

  case CASE:
    Casev = x;
    whichNumber = Speed;
    break;

  case Speed:
    Speedv = x;
    whichNumber = CASE;
    break;


  }



//-------------------------------------------------------------------

void processInput ()
{
  static int receivedNumber = 0;
  static boolean False = false;
  byte c = Serial.read ();   

  switch (c)
  {

  case EOP: 
    if (False)
      processNumber (- receivedNumber);
    else
      processNumber (receivedNumber);

    // fall through to start a new number
  case SOP:
    receivedNumber = 0;
    False = false;
    break;

  case '0' ... '9':
    receivedNumber *= 10;           // receivedNumber = recievedNumber*10 increments decimal places
    receivedNumber += c -'0';      //receivedNumber = recievedNumber + (c - '0') goes from char to decimal         
    break;

  case '-':           // What is this for?
    False = true;
    break;

  }
}

I have enough grasp on this code to use it but it bugs me that I do not fully understand it.
Is processInput a special function in the Arduino language?
What is the case '-' for? Does this just keep the received number positive?
processInput is not "Arduino language", it is defined right there in your code.
It examines the current character coming in, and if it is a '-', it takes note that the number that follows should be a negative number.  If the variable were named "isNegativeNumber", it would be clearer.

seealso http://arduino.cc/forum/index.php/topic,145379.msg1092845.html#msg1092845
58  Using Arduino / Programming Questions / Re: Problem with setSyncProvider() [from Time Library] on: February 09, 2013, 09:45:41 am
Quote
My time library does appear to attempt a sync at the time setSyncProvider is called, so as far as I can tell your code should work.
But not JUST when setSyncProvider is called.

Yes, expectation is probably that it be called every 5 sec per
Code:
setSyncInterval(5); // Set seconds between re-sync (5s for test only)


So what is the "flawed fundamental assumption" that you think he is making?  Maybe I am making it too.
59  Using Arduino / Programming Questions / Re: Problem with setSyncProvider() [from Time Library] on: February 09, 2013, 09:02:34 am
...
Below the code I printed the serial output. In this example two times the setting of the clock did not work, the third try runs and the clock output begins.
Code:
unsigned long getNtpTime()
{
  sendNTPpacket(timeServer); // send an NTP packet to a time server
    delay(500);
   
    if ( Udp.parsePacket() ) {
     ... guts ...
     return epoch;
     }
  return 0; // return 0 if unable to get the time
}

In order to succeed, getNtpTime must get an answer back with 0.5 sec-- I wonder if this is enough to be reliable?  The examples that came with the Time library I am using uses delay(1000) here, and is different in other ways.  Which Time library are you using?  I believe I am using http://playground.arduino.cc/Code/Time.

My time library does appear to attempt a sync at the time setSyncProvider is called, so as far as I can tell your code should work.

John
60  Using Arduino / Programming Questions / Re: syntax question on: February 09, 2013, 01:15:22 am
so I'm getting numbers like B111 and B100 and my cube is 3x3x3 so wouldnt it need more bits to represent all 9 led's?

Which 9 leds?

Sorry, let me put it differently.  ledcol only varies from 0 to 2.  There are only 3 "columns"...
Pages: 1 2 3 [4] 5 6 ... 25