Show Posts
Pages: [1] 2 3 ... 94
1  Using Arduino / Project Guidance / Re: Help! on: Today at 01:00:19 pm
2 is more correct. 1 is confused. "Execution" happens in both setup and loop. It is quite possible to put all the code into setup() and leave loop empty if you only want a thing done once.
2  Using Arduino / Programming Questions / Re: How to find number of "rows" in an array of strings? on: July 28, 2014, 06:17:01 pm
and if sizeof(myString[0]) is two, that means 4 elements.

You will either need a sentinal or a global with the number of strings.
3  Using Arduino / Programming Questions / Re: How to find number of "rows" in an array of strings? on: July 28, 2014, 05:15:38 pm
You could explicitly make it an array of pointers:
Code:
char *string1 = "a";
char *string2 = "b";
char *string3 = "c";

char *mystring[] = {string1, string2, string3};

Then the sizeof(mystring)/sizeof(mystring[0]) idiom will work.
4  Using Arduino / Programming Questions / Re: How to find number of "rows" in an array of strings? on: July 28, 2014, 05:11:35 pm
Rats, darn typo, it should be
Code:
if (string[i] == NULL)...
5  Using Arduino / Programming Questions / Re: How to find number of "rows" in an array of strings? on: July 28, 2014, 04:47:08 pm
You probably need a NULL as a sentinal value, and stop processing once you reach it.

Code:
char * myString = {"s1", "s2", "s3"...NULL};

Code:
if (myString[i] = NULL)
{
    //Abandon Ship!
}
6  Using Arduino / General Electronics / Re: Component to connect parts in parallel on: July 28, 2014, 11:16:04 am
And to me "tin foil hat" sounds much better than "aluminum foil hat".
7  Using Arduino / Programming Questions / Re: what does this statement mean? from virtualwire library on: July 25, 2014, 03:12:44 pm
if i have b=a, is b the same thing as a? No. It might have the same value, but if I change b, it has no affect on a.

But if I have
Code:
int * addr_a = &a;
int *addr_b;

and I say addr_b = addr_a; then if I say *addr_b = 42 it will change a, too.

Not the same thing at all.
8  Using Arduino / Programming Questions / Re: what does this statement mean? from virtualwire library on: July 25, 2014, 10:11:18 am
A computer memory location has an address and contains some pattern of bits. A 'type' is used to tell the computer how to interpret those bits. So if the type is 'char', the computer considers it a small binary number, an 'int', means that that location is part of a larger binary number and 'float' is a binary number with a mantissa and exponent.

A pointer is the address that points to that location. The type of the pointer is important because it tells the compiler how big the item is. So a char * pointer points to one memory location, an int * points to a memory location that requires two memory locations to make up the whole value and a float * uses four memory locations.

This is important, because the compiler uses this to correctly increment a pointer. if you increment a char* pointer, the compiler adds 1 to the address to get the next char, for an int the compiler adds 2 to the address and so on.

In this case, while there are some subtle differences in the type between char and uint_8, they are equivalent enough in this context to cast one to the other.
9  Using Arduino / Programming Questions / Re: print(negativeInt ,BIN) not working as expected on: July 25, 2014, 09:26:36 am
In my K&R example limits.h, the min value is -32767, you might have created a long constant.
10  Using Arduino / Programming Questions / Re: #define - compiler-linker precedence on: July 25, 2014, 09:23:58 am
Well, it is possible:
http://cobolforgcc.sourceforge.net/

For the OP, it would be safest to precede the new #define with an #undef, to make sure the compiler forgets the first one and make it clear that this is your real intention and you did not re-define by mistake.
11  Using Arduino / General Electronics / Re: Component to connect parts in parallel on: July 25, 2014, 09:06:43 am
A thin layer of copper *is* a wire. Though you might call it a bus bar. Should work fine.
12  Using Arduino / Programming Questions / Re: const int / int on: July 23, 2014, 01:12:50 pm
Take it up with K&R, then.
Code:
"This is a string constant"

has a type of array of characters, and in fact you can even do something like this:
Code:
"abcdef"[5]

to refer to the 'f'.

or
Code:
5["abcdef"]

If you want to obfuscate.

http://c-faq.com/aryptr/joke.html
13  Using Arduino / Programming Questions / Re: Help needed, How do you set Arduino internal clock with GPS NMEA on: July 23, 2014, 01:04:44 pm
The arduino has no system clock, so the SD  library just writes some default file create time, probably zero. You will have to change your SD library to change that.
14  Using Arduino / Programming Questions / Re: Help needed, How do you set Arduino internal clock with GPS NMEA on: July 23, 2014, 10:21:05 am
Just log the GPS time to the SD card. No need to "sync" the non-existent Arduino internal clock.
15  Using Arduino / Programming Questions / Re: const int / int on: July 23, 2014, 09:27:07 am
I disagree, econjack. A string constant has a type of "array of characters" and so decays to a pointer to its first element when used as in AWOL's example.
Pages: [1] 2 3 ... 94