|
231
|
Using Arduino / Programming Questions / Re: How to know the inside Arduino IDE language?
|
on: March 12, 2012, 09:13:10 pm
|
|
Hmmm well I slightly mistaken said 'box'... Yeah since it is open source so all is open...
But in C++ I never found digitalwrite, randomSeed, etc... Could you help me how I understand the function (digitalwrite,etc) in the place you state before :install path/hardware/arduino/cores/arduino/?
|
|
|
|
|
232
|
Using Arduino / Programming Questions / Re: About randomSeed(analogRead(0))
|
on: March 12, 2012, 09:06:41 pm
|
.....the function call random() runs an algorithm that creates a pseudo-random value based on a seed.
Since reading analogRead(0) would be an effectively random value, this effectively, gives you a random seed.
Thank you for the reply. what do you mean pseudo-random? why you state that analogRead(0) would be an effectively random value? How to know that?
|
|
|
|
|
233
|
Using Arduino / Programming Questions / How to know the inside Arduino IDE language?
|
on: March 12, 2012, 08:58:02 pm
|
So far I have talked to many IT programmer that this Arduino programming using C++ language... And they said that yes it uses C++ but using Arduino IDE so it put into 'boxes'... For example: they never found 'digitalwrite' in C++, but it is found here... I wonder how I open the box so I can get the pure C++ language, anyone could help me? I hope you could understand what I'm trying to say, dont hesitate to reply/ Thank you 
|
|
|
|
|
236
|
Using Arduino / Programming Questions / Re: void pointers * something
|
on: March 06, 2012, 04:13:38 am
|
|
This part is clear for me... I just think it is not equivalent with this:
*p = *q; ++p; ++q;
here, 1.get the value of q 2. equal it to the value p get 3. the address pointed by p is increased 4. the address pointed by q is increased
if so, it will not give equivalent result as above one.
|
|
|
|
|
237
|
Using Arduino / Programming Questions / Re: void pointers * something
|
on: March 06, 2012, 03:43:06 am
|
I'm trying to digest it,because I also see there is void* data...hmmm How about this: If we write: *p++ = *q++; Because ++ has a higher precedence than *, both p and q are increased, but because both increase operators (++) are used as postfix and not prefix, the value assigned to *p is *q before both p and q are increased. And then both are increased. It would be roughly equivalent to: *p = *q; ++p; ++q; Like always, I recommend you to use parentheses () in order to avoid unexpected results and to give more legibility to the code. I dont really get the equivalence between that two.. Could someone help me?
|
|
|
|
|
238
|
Using Arduino / Programming Questions / void pointers * something
|
on: March 06, 2012, 03:16:03 am
|
I am studying about pointer for my arduino project sake, and I found confusion here: http://www.cplusplus.com/doc/tutorial/pointers/#include <iostream> using namespace std;
void increase (void* data, int psize) { if ( psize == sizeof(char) ) { char* pchar; pchar=(char*)data; ++(*pchar); } else if (psize == sizeof(int) ) { int* pint; pint=(int*)data; ++(*pint); } }
int main () { char a = 'x'; int b = 1602; increase (&a,sizeof(a)); increase (&b,sizeof(b)); cout << a << ", " << b << endl; return 0; } what does it mean pchar=(char*)data; ?
|
|
|
|
|
239
|
Using Arduino / Programming Questions / Re: "Return" question
|
on: March 05, 2012, 11:35:07 pm
|
what's wrong with my modifying code so I can return: void blinks(int a) { int a = random (1,3); if (a==1) { digitalWrite(9, HIGH); // set the LED on return; } else { digitalWrite(9, LOW); // set the LED off blinks(int a); } } it appears warning message: sketch_mar06b.cpp: In function 'void loop()': sketch_mar06b:2: error: too few arguments to function 'void blinks(int)' sketch_mar06b:119: error: at this point in file sketch_mar06b.cpp: In function 'void blinks(int)': sketch_mar06b:127: error: declaration of 'int a' shadows a parameter sketch_mar06b:136: error: expected primary-expression before 'int'
|
|
|
|
|