Show Posts
Pages: 1 ... 2148 2149 [2150] 2151 2152 ... 3393
32236  Using Arduino / Programming Questions / Re: How do I write this rgb function on: February 01, 2012, 10:53:02 am
OP: In your code, RGB is not a type. The type is struct RGB.

dsw00d's approach works, but I prefer to separate the struct definition from the typedef statement.
Code:
struct rgb
{
   byte red, green, blue;
};

typedef struct rgb RGB;
32237  Using Arduino / Programming Questions / Re: Accelerometer recognising foot movements. Help needed on: February 01, 2012, 08:18:05 am
Quote
if the motion equals <224
Less than 224 what? Furlongs per fortnight? What unit of measure is motion?

An accelerometer measure acceleration, not motion. You need to integrate once to get velocity, then integrate again to get distance.
32238  Using Arduino / Programming Questions / Re: Best way to count events per hour? on: February 01, 2012, 07:55:00 am
Quote
Would (alarmCount/(millis()/3600000)) be the best way?
millis()/3600000UL will tell you how many hours have passed, not what hour it is.

Of course, if you are interested in the number of events per period of time, then the thing to do is make a note of when the period of time started, and count events until the desired interval has elapsed. Then, output the number of events, and reset the start time (to now) and the event counter (to 0).

Quote
Early on in the monitoring it seems to have too many digits for my lcd to handle.
Because you are not counting events per hour. You are counting events since time started divided by time since time started.
32239  Using Arduino / Programming Questions / Re: IR Interupts on: February 01, 2012, 06:49:55 am
Quote
Basically I have 9 functions each doing different LED patterns on my Arduino.

I also have a function that reads my IR sensor and returns back if button as been pressed (1 through 9).
That was hard to see from your code.

Quote
What I want to do is to break out of the current LED animation and switch to which ever the user has selected, I don't want to wait for the current animation to finish before checking to see if there has been an IR code received as some of the animations loop forever.
Then, it is time to re-write those animations.

You really want to implement a statement machine, and get rid of every single delay in your code.

Look at the blink with delay example. While there may appear to be a lot of states to deal with, you can't make a responsive application using delay.

As a stop-gap, you need to call the IR reader function more often (in each do-something function) and return from that function if a button was pressed.
32240  Using Arduino / Programming Questions / Re: serial read problem on: February 01, 2012, 06:32:35 am
Quote
I really have no other idea's...
I don't either, and that code is impossible to read. There are conventions, like one statement per line, for a reason. Follow the conventions if you expect others to help you debug your code.
32241  Using Arduino / Installation & Troubleshooting / Re: Newbie trouble uploading on: February 01, 2012, 06:28:34 am
There is a whole section of the forum for these issues. You are not having a programming problem.
32242  Using Arduino / Programming Questions / Re: @includes at compilation on: February 01, 2012, 06:20:45 am
Quote
Whatever file extension I gave variabls, be it .h or .c or .cpp or .ino, the compiler gives me the error " 'xxxx' was not declared in this scope " at the first variable in the project file tester.ino; the compiler just does not look whether something is declared later on, whether specifically "#include"d or not. I guess that means switching to VC++ or AVRStudio.
Personally, I think it means learning what the heck you are talking about.

One does not give variables file extensions.

You need to quit waving your hands and ranting, and post your file being included (with the proper extension), the sketch that it is included in, and the EXACT error message that the compiler generates. And, ALL of the messages.

Most people are able to use include files with no problems.

And, if you think that switching to another IDE will make life easier, you are in for a major disappointment.
32243  Using Arduino / Programming Questions / Re: Adding sensor readings? on: February 01, 2012, 05:58:17 am
Quote
TempVal = StoredVal \\ Saves last sum
StoredVal =  TempVal + Value \\ adds last sum with new number
Why make a copy of the previous total when you are going to alter the previous total anyway?

Do it all in one step:
Code:
Sum += analogRead(pin);
32244  Using Arduino / Programming Questions / Re: displaying digits on a 4 x 7 segment LED display on: February 01, 2012, 05:44:11 am
If you don't need to preserve the value in num, the code can be a lot simpler.
Code:
int num1 = num/1000;
num -= num1 * 1000;
int num2 = num/100;
num -= num2 * 100;
int num3 = num/10;
num -= num3 * 10;
int num4 = num;

If you do need to preserve the value in num, make a copy, and operate on the copy.
32245  Using Arduino / Programming Questions / Re: Arduino Uno + Xbee Shield + microSD Shield HELP on: February 01, 2012, 05:38:44 am
If the XBees are communicating with each other, then all you are looking at doing is having one Arduino read an SD card, and send that data, and having the other Arduino receive some data, and write it to an SD card.

The SD library provided with the Arduino IDE has an example that writes data to an SD card, and an example that reads data from an SD card. These two examples provided the heart of your project.
32246  Using Arduino / Programming Questions / Re: Processing long delay on: February 01, 2012, 05:33:01 am
Quote
but if I understood correctly after the write, I should put ons.flush();?
You'd need to look at the outputstream class, to determine if the output is buffered or not. I'd guess not, since you have the option of wrapping the instance in a buffering class. If the output is buffered, flush() should send the data in the buffer, even if the buffer is not full. If the output is not buffered, then flush() does nothing, and need not be called.

Quote
Also, thanks PaulS for the suggestion of listening for an input(and arduino acting as an echo), it helped me debug.
Good. It feels good when you can determine for yourself what is wrong, doesn't it?

Quote
Would it really have influenced something?
An unnecessary delay is all.
32247  Using Arduino / Programming Questions / Re: Colors in arrays help! on: January 31, 2012, 04:23:35 pm
int[] ColorsB;
ColorsB = new int[18];
int ColorsB[] = {2880,2352,3248,3088,2352,1536,2128,2304,3808,3536,3424,3376,3264,3376,3616,3840,3504,3456};
32248  Using Arduino / Networking, Protocols, and Devices / Re: HMC6352 Suggestions on: January 31, 2012, 01:50:27 pm
Quote
well its the  three last digits are varying using NMEA library
Which means that the actual position is varying no more than a few feet.

Quote
and direction  can't be Judged it some time shows 270 and some 8 degree using GPRMC.course()
Then, you are doing something wrong, or there is a bug in the course() function. A few feet variation in position is to be expected. That should not, though, cause massive changes in direction, unless you are (nearly) on top of your destination.

If you are, then course() will bounce around. Of course, if you are (nearly) on top of your destination, you should stop.
32249  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet on: January 31, 2012, 01:42:01 pm
Quote
can any body guide me regarding this
Thatta way!

You got a specific question?
32250  Using Arduino / Interfacing w/ Software on the Computer / Re: Drawing Lines In Processing Using Potentiometers on: January 31, 2012, 01:39:36 pm
Quote
That's what I'm having trouble with, assigning those floats.
You're kidding, right?

Code:
float[] colors = float(split(inString, ","));
Is in the code you are deriving from. Presumably, you are using some name other than colors for your array, since your array contains "mouse locations". If we assume that your array is called mouseLocs,

Code:
posX = mouseLocs[0];
posY = mouseLocs[1];
Pages: 1 ... 2148 2149 [2150] 2151 2152 ... 3393