Show Posts
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3082
33946  Using Arduino / Programming Questions / Re: Printing D18B20 output to lcd to 2 decimal places on: July 06, 2011, 10:24:59 am
more searching needed....
Or you could post your code...
33947  Using Arduino / Programming Questions / Re: PCF8574P and his output on: July 06, 2011, 10:12:11 am
129 posts and still no links?
33948  Using Arduino / Programming Questions / Re: Printing D18B20 output to lcd to 2 decimal places on: July 06, 2011, 09:38:03 am
However i know the sensor is capable of better resolution, i just need to get it to my display somehow
You need to match variable types with function output. If sensors.getTempCByIndex() returns an int, you won't get two decimal places of accuracy. If sensors.getTempCByIndex() returns a float, you won't get anywhere truncating that value by storing it in an int.

There are several ways to convert a float to an array of characters. Whether that is even necessary depends on what the lcd object is. If it (correctly) derives (directly or indirectly) from the Print class, it is capable of printing ints and floats directly.

Without seeing more of you code, all we can offer is encouragement. Good luck.
33949  Using Arduino / Programming Questions / Re: Printing D18B20 output to lcd to 2 decimal places on: July 06, 2011, 09:10:57 am
Code snippets lead to lousy answers, generally.

What is the type for temp4? If it is int, you can't expect to print an integer to 2 decimal places. If it is NOT int, why are you using itoa (integer to ascii) to convert it to a string?
33950  Using Arduino / Project Guidance / Re: Detect Disconnection on: July 06, 2011, 08:35:46 am
As a result I wonder how to detect if a wire is disconnected from a pin?
You can't. You need to make better connections so the wires don't get disconnected.
33951  Using Arduino / Project Guidance / Re: Water Detection Project on: July 06, 2011, 08:24:23 am
in fact using one arduino connected to one single sensor and an Xbee is a total nonsense.
Can you put the XBee to sleep, and wake it up at appropriate intervals (whatever is appropriate), without using an Arduino with each XBee?
33952  Using Arduino / Project Guidance / Re: Transfering images with Arduino on: July 06, 2011, 08:19:27 am
and we arrive at about 26.66 seconds per frame.
That's assuming that you have all the data to send. If you are also reading the data, using a serial interface, from the camera at the same rate, you'll need to double the time, or use a Mega with the camera on a different hardware serial port.
33953  Using Arduino / Project Guidance / Re: Arduino Wall Clock on: July 06, 2011, 08:13:12 am
long previousMillis = 0;

long interval = 1000;  //1000 miliseconds = 1 second

  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval)
Is interval signed to allow for negative durations? The previousMillis variable should be unsigned.

What do you expect to have happen if currentMillis - previousMillis is equal to interval? Forget it, and wait for the next pass?

    if (targetPosition > 43199)  // sweeps the clock hand back to the start position when 12hrs has elapsed
      targetPosition = 0;
      goToPosition = map(targetPosition, 0, 43199, 1, 600);
If targetPosition is 0, do you really need the map function to determine goToPosition?

  long positionMeasurement = 0;
  for(int i = 0; i<positionSamples; i++)
    positionMeasurement += analogRead(positionSignalPin);
  positionMeasurement = positionMeasurement / positionSamples;
If you need to read the position of the potentiometer more than once, you need a better quality potentiometer.

I'd add some Serial.print() and Serial.println() statements to the sketch (and Serial.begin()), to see where the sketch is hanging up. If the time until the sketch hangs were consistent, the time would give a clue. But, with different times, its harder to know where there are issues. Other than those mentioned above.
33954  Using Arduino / Project Guidance / Re: Need help finding right hardware (arducopter) on: July 06, 2011, 07:44:54 am
What I want is:
    Local storage (SDcard I guess)
    Video camera
    IR camera (preferably video)
    WiFi (want to control using PC. Don't need to control it as a "normal" RC car/plane/whatever)
    Distance sensor/sonar
The kit says that it comes with GPS and gyros.
What do you plan to store on the SD card?
What are the cameras for?
What WiFi unit do you plan on using? What range does it off/do you expect?

It'd also be nice to be able to differentiate between objects and the ground, as I want it to work in forested areas.
You will be able to. The Arduino won't. It can't do image capture/recognition. Not near enough memory or speed.
33955  Using Arduino / Networking, Protocols, and Devices / Re: Problems with DS1990R-F3 on: July 06, 2011, 06:23:35 am
I have some problems with this device.
What device? Post a link.

I used code <snip> and some errors appears.
Well, fix them. Or share them.
33956  Using Arduino / Project Guidance / Re: Would love feedback on first solo code for project on: July 06, 2011, 06:18:26 am
RunningAverage myRA(20); //Running Average

   if (samples == 300)
    samples = 0;
You are setting up a buffer to hold twenty values, then clearing it after reading 300 values. Doesn't quite compute for me. The idea behind the class is that it maintains a running average, discarding the oldest value when the internal buffer gets full. Your intervention is not needed.

   if (myRA.avg() < tempset){
        buzzerState = LOW;
Good grief, can you shut the racket off? You set the new state for the buzzer when the average temperature drops below tempset, but you never actually apply it.

long previousMillis = 0;  // will store last time buzzer was updated
This value will be overwritten by an unsigned long value, which can be quite a bit larger than a signed long value, causing previousMillis to contain a negative number. This variable should be unsigned.

long interval = 500;    // interval at which to buzz buzzer (milliseconds) for primary alarm
I guess this is signed to allow for negative intervals.

Im using a "delay(1000)" because I want to read to the serial port (9600 baud rate).
This doesn't make sense to me, either. There are no statements in your code.

If you are trying to prevent flooding the Serial Monitor with messages, a good idea, record when you last sent a value, and send again only after a suitable (unsigned) interval. Get rid of the delay().
33957  Using Arduino / Networking, Protocols, and Devices / Re: GPS receiver module on: July 06, 2011, 05:50:26 am
I now have a working unit hooked up, but my code is not uploading.
You'll have to disconnect the GPS to upload new code to the Arduino. Or, use pins other than 0 and 1, and use NewSoftSerial to communicate with the GPS.
33958  Using Arduino / Programming Questions / Re: Servo Control on: July 06, 2011, 05:19:59 am
This is my code for one servo
  myservo1.attach(3);  // attaches the servo on pin 9 to the servo object
So, which of the 6 servos is a, and which is b? What controls the rest of the servos?

while (Serial.available()) {
    if (Serial.available() >0) {
      char c =;  //gets one byte from serial buffer
      readString += c; //makes the string readString
Under what circumstances does the delay(1) statement get executed? Only when there is one or more bytes of data in the serial buffer.

So, after the delay(), during which more data might have arrived, but none can have gone away, why is it necessary to check for data in the buffer again?

Why are you waiting to read the data, anyway?

You are expecting a single numeric value to control the servo's position. You need to change that expectation to one of two scenarios.

First, the input can be a numeric value OR a letter. If it is a letter, that defines which servo to move later, but causes no movement. If it is a numeric value, that defines the new servo position. Move the specified servo, if one has been specified (by letter), to the new position.

Or, the input can be a letter, a delimiter, and a number value. The delimiter is optional if there will never be more than 26 servos. Extract the servo to move letter, and convert the rest to a value.
    char servoLetter = readString[0];
    readString[0] = '0';
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray);
Then, use a switch statement with cases for each letter/servo to move the correct servo.
33959  Using Arduino / Interfacing w/ Software on the Computer / Re: PWM Slider and Processing on: July 06, 2011, 05:07:08 am
If my mouse is over forward, I want it to move forward at the speed that the slider is set to.
An end of string marker may not be good if it is continuously reading.
When the mouse is moved over "forward", the Processing app will send ONE command to move forward at some speed, followed by an end of packet marker.

When the mouse is moved off "forward", the Processing app will send ONE command to stop, followed by an end of packet marker.

An end of packet marker is necessary. There will be no "continuously reading" going on.

Now, if you mean that you have a "scroll bar" defined as "forward", then there should be a value changed callback. When that callback is invoked, it should send ONE command to move forward at some speed, followed by an end of packet marker.

But, regardless of how the form is defined, there need not be any "continuously reading" going on.
33960  Using Arduino / Programming Questions / Re: Adding delays between operations on: July 06, 2011, 04:32:53 am
Should this be so difficult?
It is NOT difficult. It simply requires a different approach. You need to think about how YOU would do the task(s).

If you need to do something on a periodic basis, you can perform the task, set a timer for the required wait period, and not do a thing until the timer goes off. When the timer goes off, you perform the task, set a timer for the required wait period, and not do a thing until the timer goes off. Repeat forever.

Or, you could perform the task, note the time, and do other stuff. Periodically, you check to see if it is time to perform the task again. If it is, you perform the task, note the time, and do other stuff. If not, you just do other stuff.

The first method is what the delay() function is all about. The second is what the blink without delay example is all about.
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3082