Show Posts
Pages: 1 ... 129 130 [131] 132 133 ... 361
1951  Using Arduino / Programming Questions / Re: How to make arduino do 2 things at once on: July 26, 2013, 02:03:25 pm
Please run the sketch I put up in reply #6 and you will see what happens at rollover.
Change the numbers, ask about HEX if you need as that is just an easy way to read bits.

Computer binary maths are not the same as paper and pencil decimal maths.

1952  Using Arduino / Programming Questions / Re: Check if some of the buttons was pressed while executing a "for" loop. HELP! on: July 26, 2013, 12:46:25 pm
looks like you are calling rgb();
from within rgb()

There is the major problem. rgb() runs rgb() with no escape until the return addresses stack down to overwrite the heap (your variables) after a very long time.

The delay just slows it all down and keeps your code from noticing a pressed button.

Learning BlinkWithoutDelay from your IDE examples (can be reduced to 12 lines of code not counting the comments) is the first step in learning real-time code with Arduino. It's funny how hard less than 20 lines of code can be to follow.

1953  Using Arduino / Programming Questions / Re: How to make arduino do 2 things at once on: July 26, 2013, 12:18:33 pm
If you want to get the whole 49 days, 17 hours, 2 minutes and 47.296 seconds possible then unlike the official example in the IDE you have to use unsigned long for -all- of the time variables. The ones to 'fix' (add unsigned in front of long) in the example are
long previousMillis = 0;        // will store last time LED was updated

long interval = 1000;           // interval at which to blink (milliseconds)

Morris Dovey put up a timer library that uses 64-bit unsigned long long variables good for well over 500,000 years using micros() instead of millis(). I don't remember where to find it though.

Here is a sketch that uses unsigned math and shows the results in DEC, HEX and BIN.
unsigned long a, b, c;

void setup() {
  Serial.begin( 9600 );
  a = 0xffffff00UL;
  b = 0x10UL;
  Serial.println( "\n unsigned math\n" );
  Serial.print( "a = ");
  Serial.print( a, DEC );
  Serial.print( " = 0x");
  Serial.print( a, HEX );
  Serial.print( " = 0b");
  Serial.println( a, BIN );
  Serial.print( "b = ");
  Serial.print( b, DEC );
  Serial.print( " = 0x");
  Serial.print( b, HEX );
  Serial.print( " = 0b");
  Serial.println( b, BIN );
  if ( b >= a ) Serial.println( "b >= a" );
  else          Serial.println( "a > b" );
  c = a - b;
  Serial.print( "a - b = ");
  Serial.print( c, DEC );
  Serial.print( " = 0x");
  Serial.print( c, HEX );
  Serial.print( " = 0b");
  Serial.println( c, BIN );
  c = b - a;
  Serial.print( "b - a = ");
  Serial.print( c, DEC );
  Serial.print( " = 0x");
  Serial.print( c, HEX );
  Serial.print( " = 0b");
  Serial.println( c, BIN );
  c = b - (b + 1);
  Serial.print( "b - (b + 1) = ");
  Serial.print( c, DEC );
  Serial.print( " = 0x");
  Serial.print( c, HEX );
  Serial.print( " = 0b");
  Serial.println( c, BIN );
  while( 1 );

void loop() {};
1954  Using Arduino / Programming Questions / Re: function; vs function(); on: July 26, 2013, 09:23:51 am
Pointers to functions can be great.
Instead of a function with a switch-case to many functions by number that you HAVE to go through to access those functions by number, a table of pointers to the same functions can be directly accessed by index (number) faster than using the switch-case by any code that can scope that table. That's a mouthful saying how the pointer table is faster and more flexible once set up. The part I haven't tried yet is using function pointers in PROGMEM.

************* This post started out as an attempt to show how to make
int (*(*fun_one)(char *,double))[9][20];
more clear using typedef.
But between either videocard or java problems (when I'm done here, I'm going godzilla and rebuild on my java install) causing my IDE to act like it's on bad acid I've had to cut it short. My aggro-level is kind of high right now *****************

BTW, properly used, typedef (like enum) is really beautiful for code clarity and brevity.

this works in Arduino IDE 1.03 but note the comments about function address
int func( char *C )
  return ( int ) C[ 0 ];

int (*foo)(char *) = &func; // this time I use the address-of &

typedef int ( *fun_one )( char * );
fun_one myFun = func; // this time I don't use the address-of &
fun_one fun[9][20];

void setup( void )
  Serial.begin( 9600 );
  Serial.println( "test" );
  char X[4] = "123";
  Serial.println( foo( X )); // they both seem to work
  Serial.println( myFun( X ));

// the -expletive-deleted- says ambiguous whenever I try an print the function addresses
  while( 1 );

void loop( void )

Useful tutorial links:

1955  Community / Bar Sport / Re: battery density on: July 25, 2013, 05:10:07 am
If you can get a wide enough temperature differential, Peltier wafers will give you volts. Just how many you'd need depends on the situation.

In one of the Roja's video Denise shows that squirrel cage fans work very well as windmills. Why build what you can find in scrapyards? Almost every big central air unit has a major size blower. Similarly most appliance AC motors can be modified to generate power. I expect that you might bet breezes towards evening?

Put up 3 different ways to generate. One may carry the bulk of the load with another boosting the current.

1956  Community / Bar Sport / Re: battery density on: July 24, 2013, 12:22:27 pm
20 AH would be a small car battery.
1957  Community / Bar Sport / Re: battery density on: July 24, 2013, 10:21:39 am
How thick is the wire and contact that goes to a 12V 20A car fuse? How thick is the fuse?

1958  Community / Bar Sport / Re: Critical thinking and programming. on: July 24, 2013, 01:44:49 am
Sometimes my English just isn't up to a short explanation of logic so if I'm feeling up to it I throw out code or pseudocode, but I am sparing with the comments. Hey, early on I did learn a lot, including tracing code, while fixing/modifying OPC (Other People's Code) in line-number interpreter BASIC that had NO comments. For me, the code IS the comments.

1959  Community / Bar Sport / Re: battery density on: July 24, 2013, 01:37:39 am
With the heat you get, maybe a Stirling engine and generator.

Put these into the youtube search box:
GIANT DEATH RAY Daniel's DIY $25 giant parabolic
Parabolic Mirror from a Trash Can Lid
Solar Power Parabolic Trough Mirror Kit Evacuated Solar Tube
Fresnel Lens and a Stirling Engine for FREE ENERGY Solar
less than $1 a watt DIY MAKE YOUR OWN SOLAR PANEL

When I see the ones with Denise, I don't seem to be able to remember what was said.
1960  Community / Bar Sport / Re: Fake Arduino. on: July 24, 2013, 12:06:35 am
Heck, you can make/distribute my '1284 boards. Be awesome for robots.
Provides more IO, dual hardware serial, more memory. Not marked Arduino anything.

Do you sell assembled boards or is that cost-prohibitive here?

1961  Using Arduino / Programming Questions / Re: How to start a loop with a manual switch on: July 24, 2013, 12:02:51 am
It would matter if you intend to use the button once in loop().

It's also nice to know a bit about debouncing switches.

Explosives.... this old amateur pyrotechnician would want interlocks no matter how often (pretty much always) he's used green fuse (sometimes with cigarette or other slow-burn on the fuse) for ignition. Anything big, I'd want more than one switch and a cutoff.

Please note that if ===anything=== goes astray and ===anyone=== even gets close to hurt, the lawyers will eat your home-built ignition control and you alive unless you've gotten the thing certified which won't be cheap.

1962  Community / Bar Sport / Re: Hello world... on: July 23, 2013, 11:12:22 pm
Do you want to say anything about your Arduino-related (electronics & code ferinstance) strengths and weaknesses?

Bookmark these below. Each has useful info/links.

1963  Community / Bar Sport / Re: Fake Arduino. on: July 23, 2013, 11:05:34 pm

Look into compatibles as well as clones. As long as it doesn't have the Arduino name (you can use the schematic, not the name, go figure) and you don't call it Arduino then I think you're outside of violation ( ANYBODY? ).

A lot of compatibles have extra features. I for one wouldn't mind seeing an UNO with a ZIF socket. Rugged design makes UNO compatibles that can take 12V (or is it 24V) on the I/O pins. PJRC makes the Teensy's that have native USB AVR's able to be HID's without modifying the hardware. 

Maybe spread your net a bit and look into AVR boards as compatibles?

1964  Using Arduino / Programming Questions / Re: How to start a loop with a manual switch on: July 22, 2013, 09:38:19 pm
Where can I find info on what can be used in setup?  GoForSmoke, are you saying I can put a complete button routine in setup?

You can put a 1 time test in setup, and I would suggest 2 tests, one right after the other

while ( button not pressed ); // this test will happen until the button is pressed
// the next test will start before you can possibly let the button go
// next test waits for the button to be released for 1/10th of a second
// if the button 'bounces', the 1/10th second starts back up
// 1/10th second is a very long time to Arduino but a short time in button press & release
startTime = millis();
while (( button pressed ) || ( millis() - startTime < 100 ))
  if ( button pressed )
     startTime = millis();
// see what it takes to be reasonably sure? and still something may get around it!

1965  Using Arduino / Programming Questions / Re: Problem with Serial Communication Loop on: July 22, 2013, 07:34:35 pm
Thank you all for answering my question.

There's still one thing that is not clear to me... it's zoomkat's while loop

while (Serial.available()) {
    char c =;
    readString += c;

why is there a delay()?

To keep the controller from doing anything while waiting longer for the next serial character to arrive than it should, and save on actually coding an end-of-line check.
Pages: 1 ... 129 130 [131] 132 133 ... 361