Show Posts
Pages: 1 ... 1069 1070 [1071] 1072 1073 ... 1741
16051  Using Arduino / Programming Questions / Re: "Concatenating" integers? on: November 25, 2011, 06:20:18 am
Quote
Works well, except the integers are in the wrong order
You must've entered them in the wrong order.
16052  Using Arduino / Programming Questions / Re: "Concatenating" integers? on: November 25, 2011, 05:57:31 am
Just change the "10" in Mike's example to 2, 8 or 16 (plus a bit of jiggery-pokery with A-F), and you've got yourself the beginnings of a useful programmer's calculator.
16053  Using Arduino / Programming Questions / Re: Declaring variables && destroying them to free some RAM ... ?! on: November 25, 2011, 05:14:31 am
Quote
Let's say i have a function that consumes 7kB of RAM and another one that consumes the same size.
If you have a big enough stack, then the mechanism is exactly as described above.
16054  Using Arduino / Programming Questions / Re: Declaring variables && destroying them to free some RAM ... ?! on: November 25, 2011, 05:12:23 am
Quote
Local variables in functions only live as long as the function is executing
Local non-static variables in functions only live as long as the function is executing.

These variables are called "automatics", and live on the stack.
Static local variables live with the globals, and are not freed when the function exits.
Code:
void do_stuff(int i) {
  int x, y;  // these are freed
  static int a,b; // these are not freed
  // so stuff
}
16055  Using Arduino / Programming Questions / Re: a question with servo and motor on: November 25, 2011, 03:41:32 am
Think about how "loop" works.
It loops, many, many times a second.
It loops many times in the amount of time it takes to transmit a single character.
Every time through loop, you perform a Serial.read, even if there isn't a character to be read.
If there isn't a character to read, then Serial.read returns -1, which causes "stop()" to be called.
16056  Using Arduino / Programming Questions / Re: Best way to convert byte to String? on: November 25, 2011, 03:02:51 am
Code:
switch (RTCmonth - (RTCmonth/10)*10) {
    case 1:  logfilename.setCharAt(1,'1'); break;
What about October?

Edit: Forget that - default '0' in string
16057  Using Arduino / Programming Questions / Re: Help needed for code!!!! [ASAP] on: November 25, 2011, 02:56:13 am
See reply #3    smiley-wink
16058  Using Arduino / Programming Questions / Re: a question with servo and motor on: November 25, 2011, 02:50:04 am
Code:
val=Serial.read();
  switch(val)
Servos will drive themselves, but what if there is no character to read?
Your default is "stop()"

The motor probably is "working", just not for very long.
16059  Using Arduino / Programming Questions / Re: Help needed for code!!!! [ASAP] on: November 25, 2011, 02:46:48 am
Code:
#define vers = "1.01"
Like smoking, that's a habit you don't want to acquire.
16060  Using Arduino / Programming Questions / Re: Help needed for code!!!! [ASAP] on: November 25, 2011, 02:43:01 am
I imagine that starting a sketch with a closing comment symbol isn't helping.
16061  Using Arduino / Displays / Re: Timelapse with 4-digit 7 segment problem on: November 24, 2011, 11:39:38 am
A bit lacking in detail, but how about
Code:
if (currentTime-(previousTime)>=interval
?
16062  Community / Bar Sport / Re: Scorpions: ever been stung? on: November 24, 2011, 11:33:58 am
Quote
for wasps and bees and ex-special forces
They sting too?
I just thought it was a double-tap, and lights out!
16063  Using Arduino / Programming Questions / Re: two tasks at the same time on: November 24, 2011, 11:25:27 am
The response time will depend on the device type, which you haven't told us, but for CdS devices, expect decay time of around 100mS, depending on light levels.
Attack should be shorter.
16064  Using Arduino / Programming Questions / Re: Charlieplexing code on: November 24, 2011, 09:10:20 am
delay(.5)  does not pause for 500us
16065  Using Arduino / Programming Questions / Re: Returning a pointer to an array on: November 24, 2011, 02:56:52 am
Where does the function create the array?
Pages: 1 ... 1069 1070 [1071] 1072 1073 ... 1741