9 votes
Accepted

"Best" architecture for handle events

Coming from the Web world, you are most likely used to work in a single-threaded environment (save for Web workers). You have been trained to program in a non-blocking fashion, as blocking the browser'...
Edgar Bonet's user avatar
  • 42.2k
6 votes

Direct port manipulation takes 300 nanoseconds to execute for some reason

Remember: every single thing the CPU does takes time. Here is a disassembly of your loop(): ldi r25, 0b00001000 ; r25 = B00001000 1: in r24, PORTD ; r24 = PORTD eor r24, r25 ; ...
Edgar Bonet's user avatar
  • 42.2k
5 votes
Accepted

How does the compiler/assembler work wrt bootloader?

On the Uno and similar AVR-based boards, the compiler and assembler are not aware of the bootloader. The compiled program starts at address zero. There you have the interrupt vector table, starting ...
Edgar Bonet's user avatar
  • 42.2k
5 votes

Arduino uno weird behavior on a simple counter program

If you do something like Serial.println(580); that is 5 characters printed (3 digits, then CR and LF to end the line). Each character takes ten bits worth of transmission time (one start bit, 8 data ...
Edgar Bonet's user avatar
  • 42.2k
5 votes
Accepted

Problem when coding 4x4 keypad's key detection (without library)

In case 2: digitalWrite(columnsPins[c], LOW); for(byte r = 0; r < DIMENSIONS; r++){ if(digitalRead(columnsPins[r]) == LOW){ Serial.println(keys[r][c]); } } Since you just wrote one of the ...
Delta_G's user avatar
  • 3,220
4 votes
Accepted

How to ignore garbage values in serial communication between arduino and python

The effect that you see is type promotion, in the C++ standard called "integral promotion", which happens implicitly. Values of type char are cast to int. Commonly, and in your case too, the ...
the busybee's user avatar
  • 1,771
4 votes
Accepted

LCD I2C connection problems

Some common problems with LCD displays which incorporate an I2C backpack include: Not using the correct I2C address for the I2C backpack. Use an I2C scanner to discover the correct address. Mixing ...
6v6gt's user avatar
  • 1,020
4 votes
Accepted

Why this simple serial monitor code not working?

You seem to have the assumption, that the string "QUICK" is send as one package of characters, because you send it with one keypress from the Serial Monitor. But Serial (UART) is a "...
chrisl's user avatar
  • 15.8k
4 votes

Arduino UNO Power interruption

Do you have to upload the UNO after the applied power is disconnected? No. Does the UNO retain the code without any power? Yes. And when the power is disconnected, if the code is retained, will ...
VE7JRO's user avatar
  • 2,550
4 votes
Accepted

ERROR: return reinterpret_cast<T>(pgm_read_ptr(p));

With the info from the link Fahad provided in the comments, I can only offer a guess: Your ESP8266 board definitions are outdated and the old version of the ESP8266 board definitions contains a bug. ...
orithena's user avatar
  • 484
4 votes

Is there a way to increase the number of output pins in Arduino Uno?

As an extension to Dario.Casciato’s response, there are not only I²C I/O expanders, but also the simple 74HC595 IC, which can be cascaded and used via Arduino's shiftOut function. It needs three ...
DataFiddler's user avatar
  • 1,045
4 votes

How to compile without adding the bootloader?

Seeing .bootloader section in size output doesn't mean it's really present. It just means the sum of all three is 4152 bytes. You can check the hex file if it contains large block of data at the ...
KIIV's user avatar
  • 4,742
3 votes

Run encoder code simultaneously with other code in Arduino

can arduino actually run 2 void loop simultaneously No, it cannot. All AVR based Arduinos (like Uno, Nano, Mega) have only one core, thus they can only execute one thing at a time. The typical way to ...
chrisl's user avatar
  • 15.8k
3 votes
Accepted

Checking a thing about interrupts

See How do interrupts work on the Arduino Uno and similar boards? Yes, most interrupts will be remembered and the ISR will be executed when interrupts are enabled again, plus one more instruction has ...
Nick Gammon's user avatar
  • 37.9k
3 votes
Accepted

Unexpected Behaviour w/ Arduino Uno Calculation

This is a pure C++ programming issue, which I cover on my web site. However, since link-only answers are not allowed here, I reproduce that post below: On the Arduino (Uno) platform, what do you ...
Nick Gammon's user avatar
  • 37.9k
3 votes

DS3231 Not Matching Up Time when Arduino is Turned Off

rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); You have this line in setup that sets the date and time to the date and time that the code was compiled. That's fine to set it once, but that time ...
Delta_G's user avatar
  • 3,220
3 votes

"Best" architecture for handle events

The usual way to do things only once (at startup) is to put them in setup(). You put only statements in loop() that need endless repetitions. You can think of the underlying main function as: int main(...
the busybee's user avatar
  • 1,771
3 votes
Accepted

Timer interrupt setup for one second is too slow (~ 4 seconds)

There is a flag in TCCR1A/B called WGM12 which sets the wave generation mode (WGM) to Clear Timer on Compare Match (CTC). This causes the timer to count up to the value in OCR1A and then automatically ...
maddes8cht's user avatar
3 votes
Accepted

Why am I getting wrong compass heading using magnetometer readings?

Consider calibrating your magnetometer. Off the shelf, almost all magnetometers require calibration before making use of their data. The offset (commonly referred to as Hard Iron) and the magnitude (...
st2000's user avatar
  • 7,255
3 votes

Is there a way to increase the number of output pins in Arduino Uno?

It sounds like you are using some GPIOs ;) If you need more digital pins, you can use the analog pins as digital pins (if you didn't already). If you already occupied these pins, then I would think ...
Dario.Casciato's user avatar
3 votes

Is there a way to increase the number of output pins in Arduino Uno?

What you probably want is called an ‘I/O Expander’. They come in many different varieties based both on exact means you use to communicate with them, how many I/O pins they give you, and what you can ...
Austin Hemmelgarn's user avatar
2 votes

IRRemote send and receive same Arduino

based on the concept of user1843591 answer, i researched some more and found the example of Nick Gammon in the arduino forum. after some tweaks i came up with the following: (based on both) it uses ...
Stefan Krüger s-light's user avatar
2 votes

Elegant solution for refreshing TFT display content?

This code works well and accounts for values of different length. void textValue() { float newValue = @your input@; int numChars = String(newValue).length(); // Get the number of characters int ...
djogedj's user avatar
  • 21
2 votes

What are exactly XTAL1 and XTAL2 pins in Arduino Uno/Nano?

XTAL1 is the input and XTAL2 is the output of the oscillator. Using 8MHz internal RC oscillator instead of the crystal, you can use PB6 and PB7 as I/O, like other I/Os.
Gianluca's user avatar
2 votes

What does avrdude: Device signature = 0x000000 mean? Faulty wiring? Software issue? Incorrect tutorial?

Unfortunately the three prominent threads on the Arduino forum on this topic are closed, so their good but incomplete information is baked in time: Invalid device signature error Which references: ...
Heath Raftery's user avatar
2 votes

Rc switch library display received values only one times using serial monitor

Old post, I know but I have to add to it. The statement "transmitter.enableTransmit(10);" causes the RCSwitch library to send the message 10 times. You are receiving 4 messages; you ...
Larson's user avatar
  • 21
2 votes
Accepted

Ramping servo motor taking longer than calculated

There are two things going on here. You are printing too much to the serial port. After the first second (between 1000 and 9999 ms), each line you print is 20 bytes, including the CRLF terminator. At ...
Edgar Bonet's user avatar
  • 42.2k
2 votes
Accepted

4x3 keypad not providing any output and the output it does provide is incorrect

I determined where I was going wrong. The keypad has a different wiring compared to the traditional way of doing it. I found this this article helpful. The changes made to the code are as follows: ...
Campbell White's user avatar
2 votes

Can a three wire Electrical conductivity sensor (Sensorex CS 150) be used directly with arduino?

EC electrodes is an active sensor that requires an excitation voltage to be applied to get the result. When A DC voltage is apply to the two conductors, it caused iron to be flow from one conductor to ...
hcheung's user avatar
  • 1,277
2 votes
Accepted

Making library for arduino

Your keys variable is a 2D array of int, i.e. it is an array of arrays. In C++, when an array is assigned to a variable or passed as an argument, it implicitly decays to a pointer to its first element....
Edgar Bonet's user avatar
  • 42.2k

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