Show Posts
Pages: 1 ... 1885 1886 [1887] 1888 1889 ... 3234
28291  Using Arduino / Programming Questions / Re: Making LCD menu's: multidimensional char arrays. on: March 12, 2012, 12:30:47 pm
Quote
Apparantly, the code works fine if I use char firstrun[][ROW][CHAR] instead of char firstrun[MAX][ROW][CHAR]. Probably because of the memory limitation. Thanks!
The [] on the first declaration tells the compiler to count the initializers. Since you are only providing 2, not 100, the array only takes 2 * 2 * 16 bytes, or 64 bytes. Much less than the 3200 that the [MAX] version needs.
28292  Using Arduino / Interfacing w/ Software on the Computer / Re: debounce SimpleMessageSystem on: March 12, 2012, 12:22:17 pm
Quote
is it possible to use Bounce Library within SimpleMessageSystem library?
Why? Is your simple message bouncing?
28293  Using Arduino / Programming Questions / Re: What is the Arduino Uno Serial buffer size? on: March 12, 2012, 11:47:49 am
Quote
Is the buffer size only 62 bytes?
The buffer size is 64 bytes.

Quote
How can I get around this so I can read all 107 bytes and save them into an array?
Generally, the thing to do is read as fast as it arrives. Without seeing your code, we have no idea why you aren't doing this. There is nothing to get around, except to reading before the data is lost.
28294  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet + Virtual Wire Issues on: March 12, 2012, 11:18:07 am
The Ethernet shield is an SPI device. It uses pins 11, 12, and 13 for SPI purposes. It uses pins 4 and 10 as slave select pins. None of those pins is available for your application to use.
28295  Using Arduino / Programming Questions / Re: Convert string of variable length to floats. on: March 12, 2012, 11:06:01 am
Quote
As for the NULL terminator, the program recognizes the end of the string even without it.
Bullshit! It is the lack of the NULL terminator that causes strlen() to return the wrong answer.
28296  Using Arduino / Interfacing w/ Software on the Computer / Re: Garbled text using SoftwareSerial on: March 12, 2012, 11:04:41 am
HMRdisplay.read() returns an int.
Serial.write() takes a byte.

It is not clear why you are using a binary data function to send ASCII data.
28297  Using Arduino / Interfacing w/ Software on the Computer / Re: Interfacing Arduino with PC (2-way communication) on: March 12, 2012, 11:02:19 am
Quote
can we use x-ctu version 5.2.7.5 for 64bits window 7??
I do. Works fine.
28298  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing JMyrom ColorTracker - cant find my error on: March 12, 2012, 11:00:57 am
Code:
  for(int i=0;i<a.length;i++)
Your test for a.length == 0 in this for loop is in the wrong place. The code will never be executed, if a.length is 0, because the whole for loop will be skipped.
28299  Using Arduino / Programming Questions / Re: Arduino + Processing + SRF02 Ultrasonic Sensor + MP3 on: March 12, 2012, 10:17:12 am
Quote
I understand that inString needs a new value to stop the song from playing but i have no idea what to write. I have been searching for rewind() in the minim-library but cant really get it working.
The variable inString starts out null. It is assigned a value when serial data arrives. Once assigned a value, it can never be null again.

So, your if test should be
Code:
if(inString != null && inString.length() > 0)
{
}

Then, inside the block, you need to set inString to an empty string.
Code:
inString = "";
AFTER getting the value from it.

An else block to go with the if(i > 20) statement would be useful.

In the else block, stop the song from playing.

Quote
let me know if im unclear about anything else.
You seem to be unclear on the need to post the Arduino code. Let's clear that up right away. You need to post the Arduino code, too.
28300  Using Arduino / Programming Questions / Re: Temperature Fan Control PWM Arduino Help! on: March 12, 2012, 09:45:18 am
digitalWrite() turns the pin HIGH or LOW, one time. analogWrite() starts the pin toggling on and off, so that it's on amount is the ratio specified.

Ditch the complicated code. Write a sketch that calls analogWrite() with various values, from 0 to 200, with a 2 second delay between changes. If the fan speed does not change, the fan is not meant to be variable speed.
28301  Using Arduino / Programming Questions / Re: Analogread causing servo to misbehave on: March 12, 2012, 09:16:18 am
Quote
It could be flashing (FLASH).
OK, so then ignore everything I said about the else if. Since there clearly is another possible value, the code you have is correct (at least as far as the else if statement is concerned).

Quote
I' m having real trouble thinking of a different name
FrontDoorState would work for me.

Quote
With respect, it's not exactly the same
      if (FrontDoorLED == OFF)
      {
        // the button's pressed and LED is OFF
        // turn it ON as this is a "first press".
        //====================================
        digitalWrite(ledPin1, ON);
        FrontDoorLED = ON;
        RingBellServo.write(180);
        FrontDoorLEDTimeStamp1 = currentMillis;
      }
      else if (FrontDoorLED == ON)
      {       
        // the button's pressed and LED is ON
        // start flashing as this is a "second press".
        //======================================
        digitalWrite(ledPin1, OFF);
        FrontDoorLED = FLASH;
        RingBellServo.write(180);
        FrontDoorLEDTimeStamp1 = currentMillis;   
      }
Looks the same to me. Not all of the code is the same, but the duplicate code doesn't need to be there. On the other hand, maybe what's needed is an else block, to handle the case where FrontDoorLED == FLASH. If you add that, then you can decide whether there is anything in all three blocks that is the same, and move that stuff outside of the if/else if/else structure.

Quote
Again, with respect, not sure about this.
Well, you should be. It's your code, and you are right.
28302  Using Arduino / Programming Questions / Re: Arduino + Processing + SRF02 Ultrasonic Sensor + MP3 on: March 12, 2012, 09:04:55 am
Quote
if (inString!= null)
    i = Float.valueOf(inString).floatValue();
    if (i>20){
      song.play();

  }
So, once inString gets to be non-null, it is forever non-null. How is that a useful test?

What is sending data to the Processing application? Specifically, why is i a float?
28303  Using Arduino / Programming Questions / Re: Analogread causing servo to misbehave on: March 12, 2012, 08:31:44 am
Code:
  if (FrontDoorLED == OFF)
      {
     }
      else if (FrontDoorLED == ON)
      {
If FrontDoorLED is not OFF, what else could it be besides ON?

Some of your names still leave a bit to be desired. DoorBellTriggered is a great name. It implies that something might have happened to get us to the point that we need to do something. Then, we encounter FrontDoorRoutine. No clue what this is supposed to signify, but if it is OFF (whatever off means), we do something (that results in the servo being moved one way). If not, we move the servo the other way.

DoorBellTriggered is compared to 1 and set to 0. FrontDoorRoutine is compared to ON and set to OFF. The inconsistencies make the code hard to follow. The snippet makes it impossible to tell what type the twp variables are, or what type and value ON and OFF are and have.

There is, in the if(FrontDoorLED == OFF) and else if(FrontDoorLED == ON) blocks, the same code. That code should be moved outside the if/else if blocks.

Quote
I seem to have lost a closing bracket in my newer code after the else if routine. Surely this is adversely affecting how/when/if the else routine is operating.
The else if should not be an else if. It should be simply an else. Yes, it does look like you are doing things differently. The random indents make it impossible to determine what that is, though.

Quote
How should a servo operate?
  1) Should it:
  a) move to a position and stay there
  or
  b) should it move back when it's reached that position?
  2) If it's told to move to position 180 and then in the very next line told to move to position 0, should it complete the first move before doing the next, or does having two instructions so close together effectively cancel the first move out?
The Servo.write() methods starts the servo moving, and returns. If you issue another one before the servo has had time to move to the position defined on the first call, it will stop trying to get there, and go to the position defined in the second call. You need to add a delay() (or the millis() equivalent) between the two calls.
28304  Using Arduino / Programming Questions / Re: Missing values from data string on: March 12, 2012, 07:31:03 am
Quote
String datastring = String(IR1_pin) + "," + (monthDay) + "/" + (month) + "/" + (year) + "," + (hour) + ":" + (minute) + ":" +(second);

     //Open a file to write to
     //Only one file can be open at a time
     int IR1_val = Serial.println(value);
     int dataString = Serial.println(dataString);
You really need to pay attention to what you are doing. Serial.println() returns a value. But that value is useless, as far as you are concerned. Why you think that the meaning of the value is somehow related to dataString is baffling, too.

Using names that differ only in case is also not a good idea. Now, what from this code snippet do toy really want to print to the serial port. Hint: it isn't dataString or datastrinG or DatAString or any other combination of upper and lower case letters.

Stop storing the return value from Serial.print() or Serial.println() in a variable.
28305  Using Arduino / Programming Questions / Re: help needed to speed up function on: March 12, 2012, 05:02:15 am
Quote
is there a way to improve the speed of the function?
The modulo function is not the fastest function. Avoid it, if you can. Once you've determined the hours value, subtract that value (times the appropriate factor) from the initial value. What is left is the time in minutes and seconds.

Determine minutes,  subtract that value (times the appropriate factor) from the initial value. What is left is the time in seconds.

No modulo operations needed.
Pages: 1 ... 1885 1886 [1887] 1888 1889 ... 3234