Questions tagged [code-optimization]

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

19 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
50 views

Am I maximising my A0 readout rate with this peak-detection code?

I have a pulse going into A0 on a Nano, and want to detect the peak voltage. With low-pass filtering to slow down the input pulse I'm still reading marginally too slow. The code overall inhibits a ...
2
votes
2answers
68 views

How to move a servo with a function

Im currently moving a servo from one side to another by using the typical for loop like this: int lightON = 180; int lightOFF = 90; if (buttonState == HIGH) { digitalWrite(LED, HIGH); for (pos1 =...
2
votes
0answers
2k 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 ...
1
vote
0answers
28 views

How do I optimize this IRremote code?

I am using a ATTINY85 Digispark board with an IR receiver to light some LEDs in my project. The Digispark has a limitation that does not allow it to use the IRremote.h library. I know that there a ...
1
vote
0answers
52 views

Can a Windows 10 computer use Arduino IDE 1.8.10 sometimes AND use Arduino IDE 2.0.0 the rest of the time?

Can Windows 10 computer use Arduino IDE 1.8.10 sometimes, AND use Arduino IDE 2.0.0 the rest of the time?
1
vote
0answers
224 views

converting int or float into bytes array in arduino

I am trying to send data from one arduino to another over ethernet using udp protocol. In arduino writing data over udp is like this UDP.write(buffer, size); where buffer is an array to send as a ...
1
vote
0answers
62 views

How to stop my 16*2 lcd blink?

Here I wrote code for my weighting scale measurement. In which I added an on/off switch for my LCD display. But in defined delay time my LCD is a blink and I do not want it. I want my LCD switch on/...
1
vote
0answers
46 views

Automatic water pump Trigger System - I need my code FIXED

int out = LED_BUILTIN; int strt = 3; int stp = 9; void setup() { pinMode(out,OUTPUT); pinMode(strt,INPUT); pinMode(stp,INPUT); } void loop() { while(true) { if(digitalRead(strt) == LOW) ...
1
vote
0answers
500 views

Reduce time between two consecutive SPI transfers on ESP32

I'm trying to drive an external DAC via SPI interface using ESP32 chip. But I cannot achieve the desired speed (>1M transfers/sec, each transfer consists of 16bits). The reason is not the SPI speed ...
1
vote
0answers
37 views

Division with big constant number. Ideas to make it more efficient?

Im reading the voltage applied to my microcontroller using the internal voltage reference. Here the topic is talked, and there are some working examples. Im NOT using this examples, im using my own ...
1
vote
0answers
74 views

Dragino Lora shield for Arduino sensor use

I am new to arduino and lora technology and i have dragino lorashield for arduino Uno and dragino gateway. I have also MQ-3 gas sensor and I want to detect the alcohol value and to send it to the ...
1
vote
0answers
468 views

Optimizing Teensy 3.6 for data sampling?

So, I have a very basic project where I cycle through 8 IR individual transmitters. After setting the individual transmitter high, I cycle through all 8 IR receivers and print their values, RX_CYCLES ...
1
vote
0answers
56 views

Combining sketches

I have two codes for my to sensors and they work separately. However, I need to combine them in one program please can you help? The pulse code /* PulseSensor Starter Project and Signal Tester * ...
1
vote
0answers
261 views

FIltering, FXOS8700, FXAS21002C optimization

I'm working on an inverse pendulum project, and am using an adafruit NXP_FXOS8700_FXAS21002 along with an Arduino due, and an esp8266 (two separate projects, same code however). I'm using a Magdwick ...
1
vote
0answers
245 views

Why does the program size increase so drastically with these switch-cases?

EDIT: The problem is my op-code catch is op >= 0x20 || op <= 0x2F rather than op >= 0x20 && op <= 0x2F and so most of the switch-case was being optimised away! This is a really ...
1
vote
1answer
113 views

Arduino Mega prototype analog timer interrupts: newbie question

I am currently using an Arduino Mega with a fast vibration sensor to trigger the components operation (force sensor, temperature sensor) and also toggle sleep mode. I am very new at this and I have ...
0
votes
0answers
33 views

How to remove the delay from this LCD function?

#include "Arduino.h" #include "DFR0554.h" void lcd(); DFR0554 dfr0554 = DFR0554(); void setup() { Serial.begin(115200); dfr0554.begin(&Wire); // dfr0554....
-1
votes
2answers
35 views

multiple invdividual servo controll arduino

I want to declare 11 servo motors in my code. Is there a better way to do that than just declare everyone under each other. The reason is that i have a code that will set the rotation for one at a ...
-1
votes
1answer
417 views

Optimizing for speed using const, static, constexpr etc in a function

In an ISR I want to keep things quick. At the same time I want to limit variable scope. Storage space is not a factor. I have this line: const char trigs[] = "aAbBcCdDeEfFgGhHiIjJ"; When this is ...