Show Posts
Pages: [1] 2 3 ... 29
1  Using Arduino / Programming Questions / Re: error: expected unqualified-id before '[' token on: May 12, 2012, 07:19:25 pm

uint8_t[] key = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];

should be

uint8_t key[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };


unsigned char key[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
2  Using Arduino / Programming Questions / Re: static variables on: May 01, 2012, 10:48:34 pm
Not quite. If you call another function from within loop(), all of loop()'s variables (both automatic and static) will be preserved through the call.

If you exit loop() either with an explicit return or by "falling off the end", only the static variables will be preserved.
3  Using Arduino / Programming Questions / Re: smoothing pot input on: April 30, 2012, 02:09:19 am
4  Using Arduino / Programming Questions / Re: convert binary view to a counter? on: April 29, 2012, 11:02:03 pm
Ok, here's another approach (with a sample sketch):

typedef void (*fptr_t)(void);

void proc0(void)
{  Serial.println("proc0");
void proc1(void)
{  Serial.println("proc1");
void proc2(void)
{  Serial.println("proc2");
void proc3(void)
{  Serial.println("proc3");

fptr_t proc[32] = { proc0, proc1, proc2, proc3 };
fptr_t p;
unsigned char counter;

void setup(void)
{  Serial.begin(115200);
void loop(void)
{  if (p = proc[counter]) p();
   counter = ++counter % 32;
5  Using Arduino / Programming Questions / Re: Mathematical question on: April 29, 2012, 01:17:40 pm
Rob, it seems to me that division may reduce the number of significant bits - in which case there is an accuracy advantage to not doing division until after the multiplication.

If the division were done first, then bits would be lost - and a subsequent multiplication would magnify the error introduced by discarding those bits.

I suggest that (((unsigned long)n * n) / 10) might be a good solution.
6  Using Arduino / Programming Questions / Re: Arduino lookup way to do this? on: April 28, 2012, 09:28:21 pm
Any idea?


Minimum and maximum voltage values?

If voltage doesn't match a table entry, do you want to
  (a) Use lower voltage from table?
  (b) Use higher voltage from table?
  (c) Interpolate?
7  Using Arduino / Programming Questions / Re: Conversion from int/hex to char on: April 28, 2012, 12:03:53 pm
int value = 0xB0;

void setup(void)
{  Serial.begin(115200);

void loop(void)
8  Using Arduino / Programming Questions / Re: Conversion from int/hex to char on: April 28, 2012, 09:16:24 am
AWOL contributed
char charValue = ~0;

Yuppers, there are a lot of expressions that evaluate to all-bits-on.   smiley-mr-green
9  Using Arduino / Programming Questions / Re: Conversion from int/hex to char on: April 28, 2012, 08:37:04 am
But what's stored if I do 'char charValue = "0xFF" ' ?

That should produce an error because you declared charValue to be a single char and "0xFF" is four characters plus a NUL terminator.

If you want charValue to be initialized to all-bits-on, you'll need to code
char charValue = 0xFF;
without the quotes. If you do that, your result will be as SurferTim describes.
10  Using Arduino / Programming Questions / Re: problems with changing values in an array \:-| on: April 27, 2012, 10:41:29 pm
My thanks to El Supremo for the correction, and my apologies to rtty21 for getting that backward.

This is a spectacularly inefficient way to store pixels for a character generator. I'd suggest re-thinking this solution so as to store eight pixels (or at least six) per byte. The savings would provide enough freed-up space for multiple tables that didn't need any of what you're trying to do here.

Using those tables directly from FLASH should free up a reasonable amount of RAM...
11  Using Arduino / Programming Questions / Re: Error in a switch() statement! Please help! on: April 27, 2012, 09:18:30 pm
You need to specify at least the first dimension of TEMPdisp.

   TEMPdisp[6][] = { ...
12  Using Arduino / Programming Questions / Re: Conversion from int/hex to char on: April 27, 2012, 08:19:55 pm
You could use sprintf(), but how about (for values in the range 0x00 - 0xFF):

char c2h(char c)
{  return "0123456789ABCDEF"[0x0F & (unsigned char)c];

13  Using Arduino / Programming Questions / Re: Audio Delay on: April 27, 2012, 10:23:46 am
I did a bit of tweaking on my QuadRAM this morning to write and verify 8-byte (unsigned long long) data and got

Writing  512K QuadRAM (412432 usec)
Checking 512K QuadRAM (449696 usec)
512K test completed in 862128 usec.

So there may be some considerable merit to dxw00d's suggestion of Mega+QuadRAM.
14  Using Arduino / Programming Questions / Re: Sending a command from PC to Arduino on: April 27, 2012, 06:49:53 am
Sure - you'll need a PC program to send a message and you'll need some code in your Arduino to read and interpret the message received from the PC.
15  Using Arduino / Programming Questions / Re: Real help asked!!! on: April 26, 2012, 05:00:13 pm
Ok - my final replay (best I can do with the info you've provided and the code you've shown):

#define InSw ?
#define OutSw ?
#define CylAct ?


void retract(void)
{  digitalWrite(CylAct,DEACTIVATE);    // Deactivate the cylinder
   if (!digitalRead(InSw))             // Nothing to do if already retracted
      // Code to allow reverse flow of hydraulic fluid from cylinder
      // so weight can retract cylinder by gravity while pump running (?)

      while (!digitalRead(InSw));      // Wait for retraction to complete
   }                                   //  end: If retraction needed
}                                      //  end: retract()

void extend(void)
{  if (!digitalRead(OutSw))            // Nothing to do if already extended
   {  digitalWrite(CylAct,ACTIVATE);   // Activate the cylinder
      while (!digitalRead(OutSw));     // Wait for full extension
      digitalWrite(CylAct,DEACTIVATE); // De-activate cylinder to allow retract
   }                                   //  end: If extension needed
}                                      //  end: extend()

void setup(void)
{  pinMode(InSw,INPUT);                // Retract limit switch
   pinMode(OutSw,INPUT);               // Extend limit switch
   pinMode(CylAct,OUTPUT);             // Cylinder activation (HIGH to extend)
   retract();                          // Prepare for operation
}                                      //  end: setup()

void loop(void)
{  extend();                           // Drive hammer to sheetplate
   // Code to perform actual hammering process (TBD)
   retract();                          // Retract hammer
}                                      //  end: loop()
Pages: [1] 2 3 ... 29