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'...
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 ; ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 "...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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(...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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.
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: ...
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 ...
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 ...
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:
...
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 ...
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....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arduino-uno × 8077serial × 665
programming × 568
sensors × 500
esp8266 × 454
arduino-ide × 376
led × 323
c++ × 283
motor × 283
arduino-mega × 269
power × 239
servo × 222
i2c × 214
lcd × 214
bluetooth × 200
softwareserial × 191
arduino-nano × 173
gsm × 171
wifi × 166
shields × 166
pwm × 165
interrupt × 164
atmega328 × 156
c × 154
pins × 147