Show Posts
Pages: 1 2 [3] 4 5 ... 247
31  Using Arduino / Project Guidance / Re: Can a single gps reciever get a RTK accuracy? on: August 12, 2014, 08:03:30 am
Quote
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.
32  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.
33  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:
Code:
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()
{         
BlinkLED();
ManagePump();
}

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

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

  digitalWrite(PumpPin, PumpState);
  PumpInterval=GetPumpInterval(PumpState);
  }
}

unsigned long GetPumpInterval(int PumpState)
{
unsigned long PumpInterval;
if(Daylight())
  if(PumpState==LOW)
    PumpInterval = DAY_PUMP_OFF;
  else
    PumpInterval = DAY_PUMP_ON;
else   
  if(PumpState==LOW)
    PumpInterval = NIGHT_PUMP_OFF;
  else
    PumpInterval = NIGHT_PUMP_ON;
   
return PumpInterval;   
}

bool Daylight()
{
static bool IsDaylight=true;
int LDRReading=analogRead(LDRPin);
if(LDRReading>600)
  IsDaylight=true;
if(LDRReading<400)
  IsDaylight=false;
return IsDaylight;
}

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

    if (ledState == LOW)
      ledState = HIGH;
    else
      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.
34  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.
35  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.

Quote
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.
36  Using Arduino / Project Guidance / Re: Potentiometer Temperature Stability on: August 08, 2014, 09:42:00 am
Quote
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: http://www.adafruit.com/products/381
37  Using Arduino / Programming Questions / Re: Error compiling on: August 08, 2014, 09:33:53 am
Typo:
Code:
    digitalWrite (11.LOW);
should be  a comma instead.
38  Using Arduino / Programming Questions / Re: How to write command from Arduino to another device via RS232? on: August 07, 2014, 11:49:32 am
Quote
Card dispenser(RS232) <-->(RS232<->TTL)<-->TTL(Arduino) // pin 0 and 1

Ground too? Also, do you have RX on the dispenser connected to TX on the arduino? It's a common mistake to connect RX to RX.
39  Using Arduino / Project Guidance / Re: where/how to place "blink without delay" on: August 05, 2014, 11:05:48 am
On reflection, a state machine may well be overkill for this.

You can just use call two routines from loop, each of which runs blink without delay. One for the LED, one for the pump.

Whenever you change the pump state, set the interval that the BWD code is using depending on whether the pump is on or off and whether it is day or night.
40  Using Arduino / Project Guidance / Re: where/how to place "blink without delay" on: August 05, 2014, 08:23:00 am
Haven't written it yet because of my query...
however.....
if daylight(determined by LDR sensor) run pump for 1 hour then pause for 15 minutes ....repeat over and over
(this I can cover with your several things etc.)
until LDR sensor determines it is night.

Then run same pump for 30 minutes then pause for 30 minutes...repeat over and over until LDR sensor determines it is day again and then repeat first sequence.

During pause periods, flash an LED to show it is timing out.

State machine is a good way to go and use a blink without delay method to flash your LED all the time. What happens at day/night changeover? Do you finish what you were doing or immediately switch over to the new pump timings?
41  Using Arduino / Project Guidance / Re: Help with one wire temperature sensor project on: August 04, 2014, 06:27:16 am
For best results, post the sketch you're trying to compile, not a fragment.

However, Thermistor1 is a device address, not a temperature which accounts for the compiler errors you're getting. Look at this line in the PrintTemperature routine:
Code:
  float tempC = sensors.getTempC(deviceAddress);
Which shows how to get the temperature. Once you have it, then you can test it to control your LEDs.
42  Using Arduino / Programming Questions / Re: Writing potentiometer value to EEPROM over 255 on: August 03, 2014, 08:37:37 am
The hex is just to make it easier to see what the example does - it's not relevant to your situation.

You simply have to use highbyte and lowbyte to extract two 8 bit values from your sensor reading. Then you can write them individually to EEPROM. When it comes time to read the data back, you can use the word function to combine them again or use shift plus and operations.
43  Using Arduino / Programming Questions / Re: TFT bar graph on: August 03, 2014, 06:33:50 am
I'd start by drawing a rectangle and make the width proportional to the value you get from analogRead. Just divide the reading by 7 to get the width into the range of the pixels available on the display.

You'll need to clear the rectangle and redraw it when the reading changes or smaller values won't show the right size bar.
44  Using Arduino / Programming Questions / Re: TFT bar graph on: August 03, 2014, 06:08:21 am
Take a look at the documentation for point & rect here: http://arduino.cc/en/Reference/TFTLibrary
45  Using Arduino / Programming Questions / Re: Sending a struct over Serial.write() on: August 02, 2014, 06:00:32 am
Quote
Your best bet is probably to send the struct as a whole and reassemble it on the receiver.

That won't work between arduino and PC different packing of the struct and differnt sizes of vars..

Mark

Good point on packing and var sizes - endian issues may occur too if you're talking to a device with different characteristics (doesn't look like it here). But what does it matter as long as the receiving code knows this? It just makes the reassembly more complex.
Pages: 1 2 [3] 4 5 ... 247