Skip to main content

Hot answers tagged

10votes
Accepted

Arduino Code for Talking to an RFID Reader

I see some things that may help you improve your program. The Arduino language isn't C++ The language used for the Arduino isn't quite C and isn't quite C++, so if your goal is to learn or improve ...
Edward's user avatar
  • 66.8k
8votes
Accepted

Memory-optimizing arduino code to be able to print all files from SD card

The code has multiple possible points of improvement with respect to the Arduino Nano's memory limitations. Let's start by stating the current memory consumption. Compiling your sketch with PlatformIO ...
Maximilian Gerhardt's user avatar
7votes

Interactive shell for Arduino

#define Don't use #define for constants! #define MAX_COMMAND_SIZE 30 should be: ...
JDługosz's user avatar
7votes

Arduino library to simplify differential drive robots

General Observations The point of a library is to provide abstraction, reducing the amount of work that the user needs to do to accomplish what they want to do. This library does not provide any ...
pacmaninbw's user avatar
  • 25.7k
7votes
Accepted

Arduino library to simplify differential drive robots

It's great that you have a library that works for you, but now you should think of redesigning it. I see that class DDBot is implementing the low-level ...
G. Sliepen's user avatar
6votes
Accepted

Basic C++ IOT Weather Station

I'll assume the indentation is an artifact of pasting the code here. The big problem here is that long series of if statements. A simple improvement is to make ...
1201ProgramAlarm's user avatar
6votes

De/Serialize uint32_t from/to ASCII to use it in Arduino code

design of Public API bool sr( ... ) That is the Public API that you chose to define. That's what you're telling potential callers about your single responsibility. ...
J_H's user avatar
  • 38.9k
5votes
Accepted

Interactive shell for Arduino

Since everybody here has already provided great suggestions. I am going to try and answer only the asked questions. Remove duplicate code: have internal function ...
mangupt's user avatar
5votes

Drift correction for sensor readings using a high-pass filter

Not a full review, just some design ideas: For a realtime system, I'd probably make the sampler object guarantee to produce valid values, rather than forcing all ...
AShelly's user avatar
4votes
Accepted

This program reads from serial port, Saves this to a text file, increments file name each time it is run

Welcome to Code Review, nice first question. Don't Panic, and always take a towel with you. General Observations This may be a copy and paste error, but the level of indentation is inconsistent. This ...
pacmaninbw's user avatar
  • 25.7k
4votes

Digital clock with many functions

Just a single thing I noticed: if (not(row % 2) == 0) This code works, but only accidentally. You should have written either of these instead: ...
Roland Illig's user avatar
4votes

Digital clock with many functions

This looks like a really fun project! It's written in a fairly straightforward way, so I think I get most of it. Here are some suggestions for improving it. Avoid Magic Numbers You have a lot of ...
user1118321's user avatar
4votes

Read an image with ADNS2610 optical sensor and Arduino Uno

The pixel reading loop for( int i = 0; i < N_PIXELS; i++ ) leaves me uncomfortable. The data sheet effectively says that some reads may return ...
vnp's user avatar
  • 58k
4votes
Accepted

Arduino Conways Game of Life using FastLED

First, given that this is C++, it's surprising that you're still using C-style #defines when you could be using constexpr ...
Quuxplusone's user avatar
3votes
Accepted

Traffic Light which revolves around Serial Communication

Separate pin definitions Clearer and easier to maintain. ...
chux's user avatar
  • 35.7k
3votes
Accepted

Feedback on Traffic Light which revolves around Serial Communication

Use a common protocol file Any common constants, such as 9600 SYN, ACK, etc. strings should be ...
Reinderien's user avatar
3votes
Accepted

Interlock of some equipments in electrical power system using simple Arduino Uno code

For embedded systems, don't use the native integer types of C, nor weird custom types like byte. Always use the types from ...
Lundin's user avatar
  • 4,869
3votes
Accepted

Reading and Storing Integer from Serial Monitor

Character literals While this is technically correct: if (received != 10) // Terminate if newline char detected you're better off writing ...
Reinderien's user avatar
3votes
Accepted

4x4 Matrix Keypad on Arduino UNO

Your general idea is correct - looping over columns to find out if one of them is active, and then only looping over the rows to find out which button was pressed will be somewhat faster (as in: more ...
OpiF's user avatar
3votes
Accepted

Arduino: Change the color & color intensity of a LED periodically

I agree that the switch statement smells. One way to avoid it is to abstract LED values into the array, and let change_color_intensity operate on it: ...
vnp's user avatar
  • 58k
3votes
Accepted

Average readouts from multiple IR sensors with Arduino

The code feels overcommented. The only comment I see having some value is // Dummy sensor read (suggested when switching ADC pin) but even that shall refer to ...
vnp's user avatar
  • 58k
3votes
Accepted

Arduino code and PING))) ultrasonic rangefinder

VeryLongIdentifiersInCamelCase do not make your code explicit. They just add noise. The definition ...
vnp's user avatar
  • 58k
3votes

Arduino code and PING))) ultrasonic rangefinder

Am I not being to(o) explicit? Names are not too explicit, but verbose. Consider using standard physical units with metric units as the default: "meter, second, Volts, Amps, ...". Example, ...
chux's user avatar
  • 35.7k
3votes

Faster map function

The division is the real killer since the simple CPU doesn't have a divide instruction. Even in CPUs that do, it is very slow. If the denominator is known at compile time, the compiler can transform ...
JDługosz's user avatar
3votes

Interactive shell for Arduino

From my experience working with Arduino or the AVR architecture in general is an exercise in trying to make sure everything you need will actually fit in memory, both RAM and flash. The scary thing is ...
Emily L.'s user avatar
3votes

Bare minimum implementation of Dallas 1-wire DS2401 slave for ATtiny9

Comments I have several comments about the code comments. I see that you spent great effort to carefully align the end-of-line comments; however, there is too much wasted horizontal whitespace. This ...
toolic's user avatar
  • 11.1k
2votes

Arduino Adafruit Motor Shield v2 wrapper for parsing text into commands

Avoid regular expressions Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. -- Jamie Zawinsky Your problem is simple enough that ...
G. Sliepen's user avatar
2votes
Accepted

Vertical "moving" text on a LCD-display

waitUntilClear is always 0 when clearScreen is false ...
Adriano Repetti's user avatar
2votes

An interface for designing Arduino code

You describe what you did but you did not sufficiently describe why you did it. What problem you are trying to solve by your design? I see some major problems in your design. Uno.h does not need <...
stefan's user avatar
  • 2,979
2votes

Read an image with ADNS2610 optical sensor and Arduino Uno

Don't use #define for constants or "functions" (⧺ES.31). ⧺Enum.5 Don't use ALL_CAPS for enumerators and ⧺ES.9 Avoid ...
JDługosz's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible

close