Go Down

Topic: 30720 bytes maximum sketch size, if not enogh? (Read 8 times) previous topic - next topic

acmiilangr

what if we need more space in large project?

i know loop helps but if we need more space?


pluggy


cr0sh

#2
May 17, 2010, 07:00 pm Last Edit: May 17, 2010, 07:01 pm by keeper63@cox.net Reason: 1
Quote
i know loop helps but if we need more space?


You youngsters thinking 30k is too small an area to work in; why, back in my day with 8-bit home computers it would be a luxury to have such an amount of memory!

/oldster rant mode off

:)

If you are at a point where you need more memory for code, and you have exhausted all possibilities for reducing the size of your code to fit (ever heard of a 4k intro?), then you either move to another micro-controller with a larger program memory (such as the Mega), or you use other approaches.

Perhaps before you finalize your design, look and see if it can be made distributed and parallelized - if it can, then you could possibly use multiple Arduinos (or ATMegas), communicating over SPI/I2C in a master/slave relationship, and break the code up among each.

For instance, say you were building an Arduino-based handheld game system - you could try to put everything into a single Arduino (sound, LCD control, button sensing - oh, and the game itself), but this wouldn't be the best method.

It would be better to have one Arduino be the dedicated "master" - which would probably also hold the game and the SPI/I2C interface to the other Arduino/ATMegas. These other devices, hanging off the SPI/I2C bus, would each control one aspect of the system. One could control the LCD (maybe a KS0108 display), one could read the buttons, and one could play music and sound effects. The master device would be responsible to coordinate and interface with all of this, but you would likely write a special library for that anyhow to abstract the details away from the actual game code.

A similar thing could be done with a robot; one master could coordinate other slave devices to act as motor controllers, sensor interfaces, or other tasks. Note that this strategy should always be given thought, and should be a possible tool in your toolbag - whether you are working with micro-controllers or networked mainframes.

:)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

cr0sh

Hey Pluggy; what's that weird standalone brace for after the analogRead()?

;D
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

pluggy

#4
May 17, 2010, 07:07 pm Last Edit: May 17, 2010, 07:11 pm by stephen_t Reason: 1
A little something I was playing around with earlier, its the tail end of an if then structure........

Code: [Select]
/*

Stephen's Blink and long term clock clock accuracy

*/

int ledPin =  13; // LED connected to digital pin 13
unsigned long time;
unsigned long secloop = 1000;
unsigned long fred;
unsigned long count = 0;
int ana;
boolean liteon = false;


// The setup() method runs once, when the sketch starts

void setup()   {                
 // initialize the digital pin as an output:
 pinMode(ledPin, OUTPUT);    
 Serial.begin(115200);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{
 count = count + 1;
 time = millis();
 if (count >= 100){fred = count / 10 * 22;
 ana = analogRead(1);};
 if (time >= secloop){
   secloop = secloop + 500;
   //Serial.println(secloop/100,DEC);
   if (liteon){
     digitalWrite(ledPin, HIGH);
     Serial.print(count,DEC);
     Serial.print(" : ");
     Serial.print(ana,DEC);
     Serial.print(" : ");
     Serial.println(secloop/1000,DEC);
     count = 0;
     liteon = false;
   }
   else
   {
     digitalWrite(ledPin, LOW);
     liteon = true;
   };
 };
}


Looking again, it starts on the line above in the screenshot.   ;)

Probably a superfluous semi-colon in there somewhere........

Go Up