Show Posts
Pages: 1 ... 2250 2251 [2252] 2253 2254 ... 3390
33766  Using Arduino / Programming Questions / Re: Reading serial data and echoing it on: December 20, 2011, 06:08:53 pm
After you display a value, record the time:
Code:
showedNumber = millis();
Be sure to declare the global variable:
Code:
unsigned long showedNumber = 0;

Then, on each pass through loop, see if it is time to clear the screen.
Code:
if(millis() - showedNumber > showTime)
{
   // clear the screen
}
Again, be sure to declare and initialize the global showTime variable:
Code:
unsigned long showTime = 900000UL; // 15 minutes (use whatever value you like here)
33767  Using Arduino / Programming Questions / Re: Sending multiple variables from processing to arduino on: December 20, 2011, 06:02:23 pm
Quote
I have 2 variables in processing, a and b.
Of what type?

Quote
Sending one variable is quite easy, but how is it done with more then one?
Just like one.

Quote
How am i able to say, hey this is the value of variable a and this for variable b.(like marking them)
Are you sending in binary or ASCII? If ASCII, "A=xxx, B=yyy" would work. If binary, there is no need to label them. The bytes are sent in the order you specify.
33768  Using Arduino / Programming Questions / Re: Error = Void does not name a type?? on: December 20, 2011, 05:59:20 pm
Can you provide a link to the documentation for the Int data type? No such thing exists. int, yes. Int, no.

Code:
pinMode(DEP_TIME, OUTPUT);

pinMode(A_SIDE, OUTPUT);

pinMode(B_SIDE, OUTPUT);

//setting the reference voltage to the default setting

analogReference(DEFAULT);
All executable code, like this, belongs inside a function. This is not inside a function.

Code:
}
Put this back in your pocket. You're sure to need it in the right place, later.

You have so many things capitalized that should not be. Int, Void, For, etc. all start with lower case letters.
33769  Using Arduino / Programming Questions / Re: pwm relays on: December 20, 2011, 05:54:58 pm
Code:
  pinMode(relay1, INPUT);
pinMode(relay2, INPUT);
Are you planning on changing the mode of these pins? If not, these statements belong in setup(), not loop.

Code:
val = digitalRead (relay1 & relay2);
Please explain what you think this is doing. It isn't, but in order to fix it, we need to know what you think it is going to do, so we can supply the code to actually do that.

Code:
digitalWrite (relay1, 225);
digitalWrite (relay2, -225);
You can't use a negative value for the PWM duty cycle.

You can't PWM relays, anyway. You need to provide a link to the board you are using, and explain why you think you can cycle a relay at PWM speeds.
33770  Using Arduino / Programming Questions / Re: Reading serial data and echoing it on: December 20, 2011, 04:06:54 pm
Quote
Is that correct?
Yes.

Are you able to show anything on the LCD? Add a Serial.println() statement to echo what is received from the serial monitor, to make sure communication is working.
33771  Using Arduino / Networking, Protocols, and Devices / Re: I2C How to request 2 different data packages on same device? on: December 20, 2011, 03:56:42 pm
In between the wire.beginTransmission() and the wire.endTransmission() calls, you can call wire.write() (or wire.send(), depending on IDE version) to send the slave additional data, that it can read to decide what to return.

It might be easier for the master to just request the slave to send all data, and have the slave return the time and message. The master can then sort out the time from the message.
33772  Using Arduino / Networking, Protocols, and Devices / Re: SD Card on Arduino Nano on: December 20, 2011, 03:39:18 pm
Quote
I believe it attaches itself to the Serial.h library, however this is attached to pins D0 and D1, which is the USB line.
Why do believe this? It's wrong.

Quote
Ideally, i'd like to have the SD card on pins D10-13
Good thing that's what you'd like. Because that's where it needs to be connected.

Quote
Any ideas?
About what? Where to go on vacation? Got them.
33773  Using Arduino / Networking, Protocols, and Devices / Re: email when motion detected on: December 20, 2011, 03:36:02 pm
Code:
sendEmail()
{
{
  byte inChar;

  inChar = Serial.read();
 
  if(inChar == 'e')
  {
      if(sendEmail()) Serial.println("Email sent");
      else Serial.println("Email failed");
  }
}
Functions MUST have a return type defined. The number of { and the number of } MUST match. You've tried to violate both of these rules.
33774  Using Arduino / Networking, Protocols, and Devices / Re: HttpResponse from Arduino ethernet to Android Application on: December 20, 2011, 03:32:46 pm
I voted. Beats me what you want the poll results for, but, I voted.
33775  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield Interrupts??? on: December 20, 2011, 03:30:47 pm
Code:
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
No. No. No. Learn to use millis() to see if it is time to log the data.

Add a check for a client connection in loop(). If a connection is made, send the same data as part of a form, using client.print(), just like Serial.print().
33776  Using Arduino / Programming Questions / Re: Reading serial data and echoing it on: December 20, 2011, 02:43:19 pm
How is a packet defined? How do you know that you are starting to read a packet? How do you know when you are done reading that packet?

If the packet has start and end markers, it is easy to read all the data:
Code:
#define SOP '<'
#define EOP '>'

bool started = false;
bool ended = false;

char inData[80];
byte index;

void setup()
{
   Serial.begin(57600);
   // Other stuff...
}

void loop()
{
  // Read all serial data available, as fast as possible
  while(Serial.available() > 0)
  {
    char inChar = Serial.read();
    if(inChar == SOP)
    {
       index = 0;
       inData[index] = '\0';
       started = true;
       ended = false;
    }
    else if(inChar == EOP)
    {
       ended = true;
       break;
    }
    else
    {
      if(index < 79)
      {
        inData[index] = inChar;
        index++;
        inData[index] = '\0';
      }
    }
  }

  // We are here either because all pending serial
  // data has been read OR because an end of
  // packet marker arrived. Which is it?
  if(started && ended)
  {
    // The end of packet marker arrived. Process the packet

    // Reset for the next packet
    started = false;
    ended = false;
    index = 0;
    inData[index] = '\0';
  }
}
Where the comment says Process the packet, that can include printing the packet on the LCD.
33777  Using Arduino / Programming Questions / Re: Validating incoming GPS data on: December 20, 2011, 02:40:26 pm
Code:
if (Serial1.available())
  {
    Serial.print(Serial1.read(), BYTE);
  }
 
  //Check that there's data waiting to be read
  while (Serial1.available())
  {
    //process current byte from the logger
    if (processGpsChar(Serial1.read()))
On each pass through loop, you throw away a character read from the serial port, if one is available. Why is that?
33778  Using Arduino / Programming Questions / Re: Creating a string of floats on: December 20, 2011, 02:33:38 pm
Quote
I'm running the code at 50Hz, after about 5-6 seconds one of the tabs vanishes.
Just the tab character, or the data after it too?

Quote
Is this likely to be a memory problem, where I haven't defined the String size so it's contracting and expanding and problems arising because of this?
Yes, and no. It is likely to be a memory problem. You can't define the size of a String. It dynamically changes size (and memory usage).

You should get rid of the String object, and use a fixed size char array, instead.
33779  Using Arduino / Programming Questions / Re: DigitalWrite on Digital + Analog Pins on: December 20, 2011, 02:13:30 pm
Quote
This is exactly where I was confused. It doesn't mention anywhere that they are also referred to as pin 14,15,16..
Not on a Mega they aren't. That's why the A0, A1, etc. aliases were created. You don't need to know what actual pin number is used behind the scenes. Analog pin 0 is A0, on both the UNO and the Mega.
33780  Using Arduino / Programming Questions / Re: Creating a string of floats on: December 20, 2011, 02:10:13 pm
Quote
You can use sprintf to do that:
Actually, you can't. The %f format specifier is not supported on the Arduino.
Pages: 1 ... 2250 2251 [2252] 2253 2254 ... 3390