Questions tagged [code-optimization]

The process of improving the efficiency of a program such that is uses less memory and/or less computational time.

Filter by
Sorted by
Tagged with
9
votes
1answer
671 views

Overview of compiled code size

When I compile my code, the Arduino IDE returns the binary sketch size in byte. Is there a good way to find out (approximately) what function or what part of my code takes up how much memory in ...
0
votes
1answer
173 views

Shortening large chunks of code

Some of the code that I have is unbearably long and drives me insane. I don't know if there were simpler ways to doing what I am doing. long turn1; long turn2; long turn3; long turn4; long turn5; ...
18
votes
4answers
130k views

How can I declare an array of variable size (Globally)

I'd like to make three arrays of the same length. According to the documentation, Arrays must be defined as int myArray[10]; where 10 can be substituted for a known length (another integer), or filled ...
7
votes
3answers
1k views

How to increase life of EEPROM?

I want to store a few (8 as of now) IR codes into my Board's EEPROM. It would be great if someone could suggest a few tips to maximize the lifetime. The IR codes in my sketch are saved in array of ...
4
votes
4answers
21k views

What is better: one sprintf() or multiple strcat() and itoa()?

I was creating Arduino function which sends two int and additional chars between them and at the beginning and end of char array - then print that array to the serial port in almost real time. (For ...
2
votes
3answers
5k views

Storing an array of function pointers

I have some Arduino code that looks like: char packet = ser.read(); switch(packet){ case 'a': someobj.somefunc(); break; case 'b': otherobj.otherfunc(); ...
2
votes
2answers
331 views

Possible to condense this if statement?

I have this if statement: if (now.hour() == 5 && now.minute() == 10 && now.second() == 0 && now.dayOfTheWeek() != 1 && now.dayOfTheWeek() != 7){ Is there a way to ...
1
vote
0answers
1k views

Sending data from webserver to Arduino

Hello Arduino enthusiasts! I've been working on a keypad lock system for school lately and I need some advice.Basically, my code checks if the entered passcode is the same than a predefined passcode ...