Show Posts
Pages: 1 ... 2251 2252 [2253] 2254 2255 ... 3082
33781  Using Arduino / Programming Questions / Re: Toggling Servo output on: July 14, 2011, 04:24:47 am
Code:
  while (Serial.available() == 0);
  int val = Serial.read() - '0';
if (val == 1)
  {
  digitalWrite(SerPin, HIGH);
  }
else if (val == 0);
  {
  digitalWrite(SerPin, LOW);
  }
  Serial.flush();
Do nothing until a byte arrives in the serial buffer. As soon as one arrives, read it and set a digital pin.

Then, dump everything else that has arrived while setting the digital pin. Why?
33782  Using Arduino / Programming Questions / Re: Variable Scope Problem with Inheritance. on: July 14, 2011, 04:19:48 am
Quote
To lay it out, I am trying to modify a variable declared in the child class inside of a pure virtual method from the parent class.
I don't think this is what you are trying to do at all.

A pure virtual method means that the parent class defines the name and signature of a method that the child class must implement, but does not itself offer an implementation.

A virtual method means that the parent class defines the name and signature of a method that the child class may re-implement, and provides an implementation in case the child class does not re-implement it.
33783  Using Arduino / Programming Questions / Re: using GET function to poll server repeatedly on: July 14, 2011, 04:06:48 am
You are assuming that each call to the server returns a single letter. That is unlikely to be a valid assumption. You need to read everything that the server returns (until client.connected() is false AND client.available() is 0) in a while loop.

Then, when you make a second call, in your existing while loop, you will get another response, possibly different, depending on what the server is doing.
33784  Using Arduino / Programming Questions / Re: Timer question on: July 14, 2011, 03:58:26 am
The delay() function really should be renamed to twiddleYourThumbsAndDoNothingElseForAWhile() to get the point across that nothing else happens while delay() is going on. If you delay(oneWeek), you won't be reading the PH sensor during that thumb twiddling time.

On the other hand, if, on every pass through loop, you see if enough time has elapsed to warrant reading the pH sensor, and if so, read it, then see it enough time has elapsed to warrant running the pumps for a while, and if so, do it, you CAN do both at the same time.

The millis() function will tell you how long the Arduino has been running. If you track when the pumps were last run, you can determine if it is time to do it again. Like this:
Code:
unsigned long lastPumpTime = 0;
unsigned long pumpInterval = 7UL * 24UL * 60UL * 60UL * 1000UL;

void loop()
{
   unsigned long now = millis();
   if(now - lastPumpTime > pumpInterval)
   {
      // run the pumps
      lastPumpTime = now;
   }

   // Same concept for PH sensor
}
33785  Development / Suggestions for the Arduino Project / Re: SFTP Programming for Ethernet Arduino on: July 13, 2011, 06:27:16 pm
Quote
What is SFTP  ?
Google says Secure FTP, but how that relates to OP's post, I have no idea.
33786  Using Arduino / Programming Questions / Re: problem with email notifier on: July 13, 2011, 06:19:28 pm
If 48 == '0', then 49 == '1', 50 == '2', 51 == '3', and 52 == '4'. It would appear that you are getting a string for the number, and treating it as a number. Send your self a few e-mails, or wait a bit, and see what happens when you have more than 9.
33787  Using Arduino / Project Guidance / Re: Help Choosing Arduino and BT module on: July 13, 2011, 06:03:41 pm
How many success stories have you seen posted regarding bluetooth anything and Arduino?

That many, huh? That should tell you something.

Quote
does xbee "talk" with bluetooth devices? pc? android devices?
Your google skills failing? No, XBee doesn't talk to bluetooth stuff or Android anything.
33788  Using Arduino / Project Guidance / Re: Arduino Mega2560 and Lassen IQ GPS on: July 13, 2011, 05:56:28 pm
Why are you trying to
a) use obsolete SoftwareSerial
b) any software serial software
on a Mega with 4 hardware serial ports?
33789  Using Arduino / Programming Questions / Re: help wanted... on: July 13, 2011, 05:16:26 pm
Code:
int Butt1  ;       // startbutton

void setup() {
 
  pinMode(Butt1, INPUT);    // declare Butt1 as input
You haven't assigned Butt1 a value. You aren't connecting the switch to pin 0 are you?

Ditto for Sel2. Can't have two things on the same pin.

Code:
  Butt1 = digitalRead(2);  // button 1_Dig_in_2
So, now you are overwriting the value you didn't store in Butt1...

You should add a Serial.begin() call in setup(), and Serial.print() and Serial.println() statements in loop(), to see what is going on.

There are no digitalWrite() statements in setup() to turn on pull-up resistors. This implies that you have external pull-up or pull-down resistors. The == 1 test (should be == HIGH) implies pull-down resistors. You do have these external resistors, right?

Code:
    if ((Sell2 == 1)) // Check selector switch for auto control
      {
        Autocontrol = 1; // Autocontrol ON
      }
    else{ (Autocontrol = 0); } // Autocontrol OFF
In the end, Autocontrol ends up with the same value that is in Sel2.
Autocontrol = Sel2; is so much easier (and faster, too).

You've explained now what you want the code to do, but not what it actually does. How is the program not meeting your expectations?
33790  Using Arduino / Interfacing w/ Software on the Computer / Re: Connecting directly using RS-232? on: July 13, 2011, 04:43:35 pm
You are not, of course, required to use pins 0 and 1 (the hardware serial port). You can use NewSoftSerial and any two other pins.

Unless you have a Mega, with 4 hardware serial ports...
33791  Using Arduino / Programming Questions / Re: Help with webserver and sd card logging on: July 13, 2011, 04:38:17 pm
Code:
#include <LiquidCrystal.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>
#include <SPI.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <SD.h>
#define BUFSIZ 128
That's a lot of libraries, each of which makes demands on SRAM. Which Arduino are you using? In other words, how much SRAM do you have? Have you used the FreeMemory() function (it's search time...) to see how much SRAM you still have left? -37 is not a good number. smiley-cool
33792  Using Arduino / Programming Questions / Re: help wanted... on: July 13, 2011, 04:33:58 pm
Quote
But my program still does not work ....
Doesn't work as in doesn't do anything, or doesn't work as in doesn't do exactly what you want?

If you post your current code, with all suggested fixes incorporated, along with a description of what you expect the code to do and what it actually does, we'll be more than happy to help you get it working.
33793  Using Arduino / Programming Questions / Re: Correct If statement on: July 13, 2011, 04:21:05 pm
Quote
just snippets will not compile
This certainly wont:
Code:
array[10] = { 0b11000000, 0b11111001, 0b10100100, 0b10110000, 0b10011001, 0b10010010, 0b10000010, 0b11111000, 0b10000000, 0b10011000 };
Initialization of an entire array can only be performed when the initialization and declaration are performed in one statement.
33794  Using Arduino / Programming Questions / Re: help wanted... on: July 13, 2011, 04:16:02 pm
Quote
There is no need to have if(Sensor == 1)  -  you can write     if(sensor)  instead. If you want to test for a false statement then you will need an ! :
Perhaps it isn't absolutely needed, but it is certainly clearer to use an explicit comparison.

On the other hand, Sensor never gets assigned a value in OP's code, so it will never be 1.

I'd also suggest, OP, that as a beginner, you should get in the habit of putting every { and } on its own line, and properly indenting the code between them. It is much easier, in my opinion, to see the structure of this code:
Code:
if ( Valveauto == 1)
    {
      digitalWrite(Valve1, HIGH); // valve active
    }
    else
    {
      digitalWrite(Valve1, LOW); // valve off
    }
than this code:
Code:
if ( Valveauto == 1)
    {
      digitalWrite(Valve1, HIGH); // valve active
    }else{ (digitalWrite(Valve1, LOW)); } // valve off

What's with the extra parentheses in the else block?
33795  Using Arduino / Programming Questions / Re: can someone help me with my code? on: July 13, 2011, 04:04:02 pm
Quote
then get the code wondering for the servo movement
I've often thought that's how people wrote code for servos.
Pages: 1 ... 2251 2252 [2253] 2254 2255 ... 3082