Show Posts
Pages: 1 ... 44 45 [46] 47 48 ... 206
676  Using Arduino / Programming Questions / Re: Braces around Scalar Initializer for type 'byte' ERROR on: June 18, 2014, 11:28:39 pm
If you actually want a 2-d array,  you could try this:

Code:

byte patterns[ num_patterns ][8] = E  ;


Considering only the textual substitution aspect,  that should work.  But it seems rather pointless to go about it the way you are trying to do, anyway.
677  Using Arduino / Programming Questions / Re: Braces around Scalar Initializer for type 'byte' ERROR on: June 18, 2014, 11:24:38 pm
E is not the definition of a two dimensional array.

E is defining a textual substitution for the C preprocessor,   which looks like a set of initializers for an array,  but isn't,  unless you actually declare an array,  which you cannot do in a #define.

Furthermore,  when you use E later,  you are creating an initializer for a three dimensional array,   which the array declaration needs to match correctly.
678  Using Arduino / Programming Questions / Re: Dynamic/Variable Dependent Infinite Loop? on: June 18, 2014, 11:20:36 pm
If you want your while statement to run forever:

Code:

while ( true )
{
    //  code here will be iterated over and over again,  for ever   (  not once )
}

679  Using Arduino / Programming Questions / Re: Dynamic/Variable Dependent Infinite Loop? on: June 18, 2014, 11:18:38 pm
Quote
and the loop takes a user defined amount of time to complete one iteration. I

Well you are wrong there,   because the while loop in your function there will iterate thousands of times,    not one iteration,   until your time millis() there reaches the specified value.

And in the arduino concept,  the loop( ) function already repeats indefinitely.   You are probably better off using this to keep doing what you are doing,   rather than having the code lock up in a specific function.
680  Using Arduino / General Electronics / Re: Capacitor for Inrush Current from Motors on: June 18, 2014, 11:07:55 pm
Try to estimate either the starting current,  or the voltage drop,  when you connect the motor.

If your motor is physically obstructed from turning,  the high stall current may persist for quite a while,   and a capacitor won't help much.  On the other hand,  if the motor is immediately able to start turning,   the duration of the stall current will be shorter.

A capacitor is only going to be able to supply additional starting current,  if it is "charged up" before the relay closes the circuit to the motor.  Therefore the capacitor must be on the upstream side of the relay.   Having the capacitor on the motor side of the relay would make the startup current problem even worse,   because when you close the relay,  you would also be providing current to charge up the capacitor.   Although,   you would still want a small capacitor on the motor side to help with runtime electrical noise from the motor.

You can then ffigure out how many coulombs of extra starting current you need.   Suppose you want 1 amp of extra current for 0.1 seconds.   That is 0.1 coulombs of electric charge.   Now suppose you expect the supply voltage to droop by 1 volt,  and not more,  when you start the motor.    A charged up capacitor which is 0.1 farads will deliver 0.1 coulombs of charge when it's voltage reduces one volt.  Thats how a farad is defined.     That's a rather large capacitor but it illustrates the concept mathematically.


681  Using Arduino / Programming Questions / Re: got some questions about a code on: June 18, 2014, 10:17:58 pm
Quote
The fact that digitalWrite() does is just due to the care that was taken writing it

That's a very odd assertion.   How do you know that the person or persons who implemented digitalWrite( )  were careless ?   If they had been "paying more attention",  as you imply that they should have been,   what sort of run-time type checking do you propose that they should have implemented for the Arduino platform,  if they had been taking more "care" with what they were doing ??
682  Using Arduino / Programming Questions / Re: got some questions about a code on: June 18, 2014, 10:07:44 pm
If stat is a boolean variable,    the correct way to invert its state  is using   !stat ,  not ~stat
683  Using Arduino / Programming Questions / Re: got some questions about a code on: June 18, 2014, 09:59:48 pm
The problem over what "true" is defined as,  is a good reason for encouraging people to write

Code:

if ( stat )
{

}

instead of the silly

Code:
if ( stat == true )
{

}

Some computer languages require the second formulation, C/C++ does not.   And if "true" has the specific value of 1,    and stat is not 1,   then you can get potentially spurious behaviour.
684  Using Arduino / Programming Questions / Re: got some questions about a code on: June 18, 2014, 09:53:40 pm
I suggest that instead of randomly trying stuff,   you get a good C/C++ textbook,  and read it.
685  Using Arduino / Programming Questions / Re: Correct use of if and boolean statement? on: June 18, 2014, 09:52:18 pm
whether you use an explicit while  or rely on the repetition of loop( ),    you need to actually read the temperature and the status of the digital input pin on each iteration.

For example,   this code example won't work,  because it only reads the temperature once
Code:
int temperature = analogRead(  temp_pin );
while ( temperature > 25 )
{
   //  do something
}
686  Using Arduino / Programming Questions / Re: "not declared in this scope" on: June 18, 2014, 09:46:02 pm
Where is the declaration of all those arrays ?
687  Using Arduino / Programming Questions / Re: "not declared in this scope" on: June 18, 2014, 09:43:27 pm
Quote
I'm learning to use PROGMEM to store data (first, static data, then possibly dynamic data)

You cannot store dynamic data in the program flash memory.
688  Using Arduino / Programming Questions / Re: Reading long serial data on: June 18, 2014, 09:02:18 am
Three bytes doesn't look like a "long" to me.

You're the second person today who likes 24-bit data.
689  Using Arduino / Microcontrollers / Re: Please Help - Programming PIC18F2525 using Arduino on: June 18, 2014, 08:59:03 am
Why would you think that users of an Arduino forum know anything at all about PIC's ?
690  Using Arduino / Networking, Protocols, and Devices / Re: SPI with AD5668 (newbie) on: June 17, 2014, 11:53:49 pm
So,  when it doesn't work,   what does it not do ?
Pages: 1 ... 44 45 [46] 47 48 ... 206