Show Posts
Pages: [1] 2 3 ... 246
1  Using Arduino / Programming Questions / Re: set cursor was not declared in this scope on: August 18, 2014, 02:34:40 pm
The compile error may be related to which LiquidCrystal library you are using. Try using a different one.

Doesn't look like it - the first use of setCursor correctly uses an lcd object. The second doesn't.
2  Using Arduino / Programming Questions / Re: set cursor was not declared in this scope on: August 18, 2014, 09:43:21 am
  if (i==0) lcd.setCursor(16,0);
3  Using Arduino / Programming Questions / Re: Where can I learn programming for arduino? on: August 17, 2014, 07:58:55 am
Jeremy Blum's youtube tutorials often come up when this question is asked - disclaimer: have not watched them myself.
4  Using Arduino / Programming Questions / Re: [HELP!] Weird GPS data and micro SD card problem on: August 16, 2014, 06:19:44 am
Your GPSdata function only populates and returns struct A if there is data coming in from the gps. If there wasn't, which will often be the case because serial data transfer is slow, loop will pick up whatever happened to be on the stack and treat it as an instance of GPSstruct. As you see, that stack content is garbage.

You must ensure that GPSdata always returns a valid struct - make the return the very last line of the function. Make struct A global, or better, a static variable in GPSdata.
5  Using Arduino / Project Guidance / Re: Drink Mixer (precise liquid dispensing) on: August 15, 2014, 08:44:05 am
Here's a thread on the same topic

There's a link in there to the drinkmotizer, which does the same job but uses linear actuators to work the optics rather than raising the glass.

Optics seem like a good solution - what's giving you pause there?
6  Using Arduino / Project Guidance / Re: Where do I begin? reading data from Weather Station and display it on: August 14, 2014, 08:36:52 am
Given the size of the data stream and the general paucity of RAM on most arduinos, I'd be inclined to to try parsing it field by field as you receive it. Serial data transmission is slow compared to the Arduino clock speed so you should have plenty of time. Given the age of your weather station, I'd expect the baud rate to be pretty low too.

As you read the serial stream, keep note of which field you're on so you know how big it is and whether you want it. If you do, copy it to a little buffer and call a routine to process it, which will likely consist of a switch statement controlled by field number.

Of course, if your sketch is simple enough, you may do just as well buffering a complete packet but the above method may help when you start adding features and use up your remaining RAM.

7  Using Arduino / Project Guidance / Re: where/how to place "blink without delay" on: August 14, 2014, 06:20:24 am
My apologies - it wasn't specifically directed at you - it was a general observation - we're all idiots on occasion.
8  Using Arduino / Project Guidance / Re: where/how to place "blink without delay" on: August 13, 2014, 07:36:04 am
In this case, once I realized that two independent BWD's would do the job I took the BWD example and did a bit of copy & paste - you can see the evidence in some of the variable names I lazily left unchanged.

At that point, the LED code was complete. From there it was just top down design & functional decomposition to complete the management of the pump i.e. I tweaked the ManagePump function and when I came to a bit I didn't immediately want to do, I assumed a function that would do what I needed so I could complete the one I was working on.

That assumed function turned out to be GetPumpInterval. It in turn assumed that there would one day be a function that knows whether it is daylight or not. The Daylight function turned out to need no more support functions so that was that.

So, the LDR came last because I didn't need it until I wrote the Daylight function. It was obvious of course that it would have to be read at some point, but initially, I didn't know when that point would be.

With this approach, assuming a function you need and filling it in later, it sometimes feels that the program is almost writing itself. In a more complex piece of software, you will likely need much more design up front, but even then, you can use this technique when you get into the details - it lets you focus on a little bit of code at a time rather than worrying about the big picture.

Of course, it's not infallible - sometimes you'll find that some idiot (yourself) has painted themselves into a corner and you'll need to backtrack until you untangle the mess you've made  smiley-wink   
9  Using Arduino / Project Guidance / Re: Can a single gps reciever get a RTK accuracy? on: August 12, 2014, 08:03:30 am
even under the best conditions, the reported position wanders around in a seemingly random path

This is done by design. Its to prevent civilian uses of GPS getting a completely accurate position.

It sounds like you're talking about selective availability which did indeed introduce position error for non-military users. According to wikipedia, that 'feature' has been disabled since 2000. The variation in position observed is due to (among other things) atmospheric & space interference.
10  Using Arduino / Programming Questions / Re: The difference between while and if statements. on: August 11, 2014, 02:23:46 pm
"Arduino Cookbook" it says while and if statements are interchangeable in most cases.
In which section? I just gave the if & while parts a cursory glance & couldn't see any such thing.
11  Using Arduino / Project Guidance / Re: where/how to place "blink without delay" on: August 11, 2014, 07:26:42 am
Here's an adaptation of your earlier requirements using millis and functions:
const int ledPin =  13;     
const int PumpPin =  12;     
const int LDRPin = A0;

const unsigned long DAY_PUMP_OFF   = 60UL*60UL*1000UL;
const unsigned long DAY_PUMP_ON    = 15UL*60UL*1000UL;
const unsigned long NIGHT_PUMP_OFF = 30UL*60UL*1000UL;
const unsigned long NIGHT_PUMP_ON  = 30UL*60UL*1000UL;

unsigned long previousLEDMillis = 0;        // will store last time LED was updated
unsigned long previousPumpMillis = 0;       // will store last time Pump was updated

unsigned long interval = 1000;           // interval at which to blink (milliseconds)
unsigned long PumpInterval;

void setup()
pinMode(ledPin, OUTPUT);
pinMode(PumpPin, OUTPUT);
PumpInterval=GetPumpInterval(LOW);  // Start with the pump off

void loop()

void ManagePump()
static int PumpState=LOW;
unsigned long currentMillis = millis();
if(currentMillis - previousPumpMillis > PumpInterval)
  previousPumpMillis = currentMillis;   

  if(PumpState == LOW)
    PumpState = HIGH;
    PumpState = LOW;

  digitalWrite(PumpPin, PumpState);

unsigned long GetPumpInterval(int PumpState)
unsigned long PumpInterval;
    PumpInterval = DAY_PUMP_OFF;
    PumpInterval = DAY_PUMP_ON;
    PumpInterval = NIGHT_PUMP_OFF;
    PumpInterval = NIGHT_PUMP_ON;
return PumpInterval;   

bool Daylight()
static bool IsDaylight=true;
int LDRReading=analogRead(LDRPin);
return IsDaylight;

void BlinkLED()
static int ledState = LOW;   
unsigned long currentMillis = millis();
if(currentMillis - previousLEDMillis > interval)
    previousLEDMillis = currentMillis;   

    if (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;

    digitalWrite(ledPin, ledState);
Compiled, not tested.

It blinks a led all the time and doesn't implement your power, night or day leds. Neither does it have an led that blinks during the pump off period. All of these should be easy enough to implement with a couple more functions. Note that this approach keeps the LED and pump control completely separate and thus rather easier to follow.
12  Topics / Home Automation and Networked Objects / Re: Chicken food dispenser on: August 09, 2014, 06:37:44 am
At trigger time, start the motor. Monitor the switch until it reads zero. Delay a few milliseconds to take care of switch bounce. Monitor the switch until it reads one. Stop the motor.
13  Using Arduino / Programming Questions / Re: Scrolling Algorithm for LEDs that Follow Someone on: August 08, 2014, 02:02:32 pm
Post all of your code.

Also, after maybe 30 seconds

That's often  a sign that you've used an int variable to store millis in rather than unsigned long.
14  Using Arduino / Project Guidance / Re: Potentiometer Temperature Stability on: August 08, 2014, 09:42:00 am
can the arduino read a thermocouple or thermistor?
Yes, using analogRead, but you'll likely need additional circuitry to amplify thermocouple readings. Easier to use a DS18B20 - there are waterproofed ones:
15  Using Arduino / Programming Questions / Re: Error compiling on: August 08, 2014, 09:33:53 am
    digitalWrite (11.LOW);
should be  a comma instead.
Pages: [1] 2 3 ... 246