Show Posts
Pages: 1 ... 2148 2149 [2150] 2151 2152 ... 3066
32236  Using Arduino / Programming Questions / Re: Variable data type as function argument on: September 01, 2011, 10:24:23 am
Quote
I am working on a modified EEPROM library which allows the easy storage of ints, floats, and longs, in addition to the standard bytes.
In C or C++? If it is in C++, templates are your friend. Not trivial, but not all that difficult, either.
32237  Using Arduino / Project Guidance / Re: Some advice? on: September 01, 2011, 09:29:54 am
Quote
The system will not be taking data in for long periods of time -- it will probably only take in data for say, 6-10 of the 26 hours in a day, so waking every 500ms is still wasting a lot of power.
Long days, huh?

Quote
When I receive a signal from an accelerometer, I want the system to wake up and start taking in data.
How is the accelerometer being powered? If it is powered (off) by the Arduino when the Arduino goes to sleep, how will it ever generate any signal?
32238  Using Arduino / Project Guidance / Re: PHP serial output problem on: September 01, 2011, 08:05:30 am
Quote
How do you disable the AUTO-RESET?
http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection
32239  Using Arduino / Project Guidance / Re: Resistors for this PIR sensor on: September 01, 2011, 08:03:13 am
That appears to be a digital sensor - the output is either HIGH or LOW. That should be input to a digital pin.

Quote
As a digital input it works perfectly and as analog it seems to go between 0 and 1000.
I wouldn't expect anything but ~0 and ~1023.

Quote
but I still want to be sure I'm doing it right.
When connecting to a digital pin, yes. When connecting to an analog pin, no. It's like trying to determine the degree of pregnancy. You either are or you aren't. You can't be a little bit pregnant.

Quote
I'm using a 100kohm resistor to pull down to ground
A 20k would be better.

Quote
and a 10kohm resistor to connect to the arduino inputs.
Why? Something wrong with a simple wire?

32240  Using Arduino / Networking, Protocols, and Devices / Re: Which Xbee??? on: September 01, 2011, 06:27:17 am
Quote
I see that the XBee-Pro ZB has a 2-mile range (under the MOST optimal LOS conditions, I'm sure - but a good spec noetheless) and is on a through-hole PBC.
Do you have a link to this XBee with through hole PCB? Most XBees (all that I've ever seen) have a bunch of pins with non-standard spacing (at least non-breadboard standard) and no through holes.

Quote
Obviously this is no issue for the plane's receiver but I'm wondering if that's just because the system is made to accommodate the proximity to the motor or if it's simply not an issue?
If the motors do not affect the receiver, it is not because the receiver is immune to noise. It is because the motors have capacitors to absorb the noise.
32241  Using Arduino / Programming Questions / Re: combining two sketches help on: September 01, 2011, 04:34:08 am
Quote
But is suppose to stay HIGH isnit?.
No.

Code:
void loop(){             // this part of the sketch turns the LEDs on
  val = digitalRead(ONOFFPIN);  // read input value and store it // yum, fresh
The value in val will be HIGH while the switch is pressed, and LOW while it is released. It is not a latching switch, so val changes whenever the switch is pressed and released.

Code:
  if ((val == HIGH) && (old_val == LOW))    // check if there was a transition
The comment here describes the code almost perfectly. If val IS high, and was low (on the last pass through loop), the switch is now pressed, where it was not before. Therefore, the switch was just pressed.

This is where your problem is occurring. On the first pass through loop, when this condition is true, old_val is set to the current switch position (pressed). On the very next pass, even if the switch is still pressed, this statement causes the following code to not be executed, since no transition from not-pressed to pressed occurred.

This is not what you want. It is for the up/down buttons, because you do not want them to continue incrementing if held down, but it is not what you want here.

The if statement is fine, if the body simply increments, and resets as needed, a counter, and the code that is currently in the body of this if statement is executed only when the counter equals 1.
32242  Using Arduino / Programming Questions / Re: Wireless Serial Array problem on: September 01, 2011, 04:25:11 am
Quote
It works fine, now i can see the 5 numbers on 1 on Lcd, but how to extract the prefix and the value ?
If the prefix is always two characters, and the value always 3:

Code:
char pref[3];
char valu[4];

void loop()
{
   // Get data in inStr...

   pref[0] = inStr[0];
   pref[1] = inStr[1];
   pref[2] = '\0';

   valu[0] = inStr[2];
   valu[1] = inStr[3];
   valu[2] = inStr[4];
   valu[3] = '\0';

   int prefNum = atoi(pref);
   int valuNum = atoi(valu);
}
32243  Using Arduino / Programming Questions / Re: How to convert 4 bytes into a long? on: August 31, 2011, 05:33:33 pm
Quote
So the conversion function "long" does not seem to accept arrays and I wonder how to use it?
You don't, because that is not what it is for.

The long that you want to construct is done by shifting one of the bytes in the array 24 places to the next. Then, the next byte is shifted 16 bits to the left, and added. Then, the next byte is shifted 8 bits to the left, and added. Then, the final byte is added.

Code:
long val = 0;
val += d[0] << 24;
val += d[1] << 16;
val += d[2] << 8;
val += d[3];

Depending on how the bytes were sent, the array may need to be used in the other order (3, 2, 1, 0).
32244  Using Arduino / Programming Questions / Re: Yet another attachInterrupt() question on: August 31, 2011, 05:29:03 pm
The first argument is the interrupt vector number. On the Arduino UNO and similar boards, pin 2 is connected to external interrupt vector 0, and pin 3 is connected to interrupt vector 1.

Quote
I have a board with a 1284P and a UART tied to pin 42
Isn't there already an interrupt handling the receipt of serial data?

Quote
Below is the code from the example. I think they mean to be signaling an interrupt on pin 13, but I don;t understand how that related to pin 0 as passed to the attatchInterrupt function.
Something outside of the Arduino is sending a pulse to pin 2, which is connected to interrupt vector 0. When the pulse occurs, it ramps up, then back down. The interrupt handler identified (dataReceived) is called when the pulse begins to fall (because of the FALLING parameter).

In that interrupt handler, the state variable's value is changed. On each pass through loop, the value in that variable is used to set the state of pin 13.
32245  Using Arduino / Networking, Protocols, and Devices / Re: Maniacbug's Ethercard/Pachube sketch on: August 31, 2011, 05:19:14 pm
Quote
So to be clear, do I have to declare sd1 & sd2 as 'float's (they are currently declared as 'double'), as well as including the .0 after 1000?
Floats and doubles are the same size on the Arduino, so it doesn't matter which you use.

Quote
Also, what determines/limits the accuracy of the result, ie 10 / 3 = 3.333333 etc. In other words, can the result be limited to 3 decimal places?
The accuracy of the result is based on the accuracy of the data that was fed in, and the division algorithm in the avr code. That has little to do with the number of decimal places that you see in the result. The accuracy is generally good to 7 decimal places max. How you display that number in other places has (almost) nothing to do with the accuracy of the calculation. You are free to display the value with 48 digits after the decimal point, but doing so won't make it more accurate. You are free to display the value with fewer than 7 decimal places.

You should say something about what the stash object it. It may be converting the value to a string to send somewhere. If so, it may be derived from the Print class. If so, you can control the number of decimal places in the string representation of the number.
32246  Using Arduino / Networking, Protocols, and Devices / Re: Multi serial with Arduino Mini on: August 31, 2011, 05:02:06 pm
Quote
But I can send without problem to the two instances.
But I can send without problem from the two instances.
32247  Using Arduino / Programming Questions / Re: Wireless Serial Array problem on: August 31, 2011, 04:40:27 pm
Quote
Is that needed for read entire 5 numbers sent by Serial ?
To read 5 characters using Serial.read(), you need a 6 element array. After adding each character to the array, you need to append a NULL.
Code:
char inStr[6];

void loop()
{
  while(Serial.available() < 5)
  {
     // Do nothing (i.e. wait for 5 characters to be available)
  }

  for(int i=0; i<5; i++)
  {
     inStr[i] = Serial.read();
     inStr[i+1] = '\0';
  }

  int inNum = atoi(inStr);
}
32248  Using Arduino / Programming Questions / Re: combining two sketches help on: August 31, 2011, 04:09:24 pm
Your momentary switch only reads HIGH while you hold it down. The rest of your code only executes when the momentary switch is pressed. So, that explains why your sketch doesn't appear to work.

Try holding the switch down while pressing the up/down buttons, and see if the rest of the code works.

If it does (and it certainly looks like it will), then you can use the same logic as with the up/down buttons. Press once to enable (0 increments to 1) and again to disable (1 increments to 2, which causes a reset to 0).
32249  Using Arduino / Programming Questions / Re: Sending I2C Address through serial monitor on: August 31, 2011, 03:22:58 pm
The Serial.available() function returns the number of bytes available to read, not just a true/false value.

So, make the if statement:
Code:
if(Serial.available() >= 3)
if you want to be sure that there are 3 bytes to read.
32250  Using Arduino / Programming Questions / Re: passing char array into function on: August 31, 2011, 03:00:07 pm
Quote
I need to use the serial monitor to see what my target device's handshake response is.
If the Arduino is on one end of the serial port, and the Serial Monitor is on the other, how does the "target device" get any data? You can't have two devices on one end of the serial port.
Pages: 1 ... 2148 2149 [2150] 2151 2152 ... 3066