Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
12 votes
Accepted

delay(time); vs if(millis()-previous>time); and drift

There's one important thing that you need to remember when working with time on an Arudino of any form: Every operation takes time. Your foo() function will take an amount of time. What that time is,...
Majenko's user avatar
  • 105k
10 votes

Newbie Using Brown Out detector on Arduino Due for saving variables to eeprom?

Not a good idea - if the power goes down when you writing to EEPROM, your EEPROM data will be corrupted. The brown-out detector goal is to shut off the MCU, before it goes mad due to low power voltage....
gbg's user avatar
  • 518
9 votes

Sizeof variables and Due's RAM

sizeof doesn't return the number of elements. It returns the number of bytes. Since they are uint16_t arrays each element is 2 bytes - hence twice the size. The reason your last number is only 40928 ...
Majenko's user avatar
  • 105k
8 votes
Accepted

Faster Arduino Mega

You should begin working with 3.3V. 5V is getting rarer and rarer as far as "real world" applications go. Many devices that you have been using at 5V will also work at 3.3V (such as the MAX22500E). ...
Majenko's user avatar
  • 105k
7 votes

Only getting error from ESP8266 AT commands

The AT firmware responded with ERROR because it received data, but timed out waiting for the CR/LF line ending. AT commands must be terminated with Carriage Return '\r' and Line Feed '\n' control ...
Juraj's user avatar
  • 18k
7 votes
Accepted

Memory allocation on Arduino Due never returns NULL

Why This is a partial answer, for now, mostly with regard to: Why does malloc() never return NULL? So, the Due appears to use Newlib as its libc implementation; that is the systems C (standard and ...
timemage's user avatar
  • 5,299
6 votes
Accepted

How do I read from /dev/ttyACM0 in Linux without a terminal emulator?

I have had very similar problems with my yun(shields) and I found the stty command to be very crucial for a good working. I use following command and it works with mega and due on the yun stty -F ${...
jantje's user avatar
  • 1,382
6 votes
Accepted

Arduino Due vs Mega 2560

The 'R3' version boards and shields are compatible with 3.3V and 5V. For example the Ethernet Shield V1 version 'R3' can be used with the Due. The new Arduino Ethernet Shield 2 is also compatible with ...
Jot's user avatar
  • 3,246
5 votes

Arduino is not responding to a Tiny RTC I2C modules, How to fix?

You have a couple of problems (although the lack of pull-up resistors is not one of them, because the board you linked has pull-up resistors on it). The DS1307 needs to operate at a minimum of 4.5 ...
Nick Gammon's user avatar
  • 38.3k
5 votes

Arduino Time Clock Accuracy

Re-visiting an old question... as I found a very informative blog post that sheds new light into it. But let me first provide some context before giving the link. When assessing the quality of a time ...
Edgar Bonet's user avatar
  • 43.2k
5 votes

Arduino Due vs Mega 2560

The Due can do a lot of things much faster. It has more memory and far more processing power. It has more flexible and more powerful built-in peripherals. It can't easily interface with 5V devices ...
Majenko's user avatar
  • 105k
5 votes

How to connect Arduino 5v pin with multiple things?

5V is just 5V. It's not a signal, it's just a voltage level. If you need to connect multiple things to it then just connect multiple things to it. If that means connecting wires together then so be it....
Majenko's user avatar
  • 105k
5 votes
Accepted

How to enable exception handling on the Arduino Due?

First, we must make sure the "-fno-exceptions" compiler flag is overwritten with "-fexceptions". In addition, we must link a separate library that includes the compiler support ...
PMF's user avatar
  • 1,296
4 votes
Accepted

Programming Arduino in Pascal?

Not Pascal, but Ada, which is much less restrictive than Pascal while enjoying the same advantages over low-level programming, and much more actively supported with language revisions as recently as ...
user_1818839's user avatar
4 votes
Accepted

Arduino onboard LED pin number as a constant

#define LED_BUILTIN 13 (source)
Gerben's user avatar
  • 11.3k
4 votes

Arduino onboard LED pin number as a constant

Try LED_BUILTIN: pins_arduino.h:static const uint8_t LED_BUILTIN = 13;
Majenko's user avatar
  • 105k
4 votes
Accepted

fatal error: avr/io.h: No such file or directory

The Due is SAM architecture. avr/io.h is specific to the AVR architecture of the Uno's microcontroller. The compiler will not look in the avr tools folder for that file and even if it did it wouldn't ...
per1234's user avatar
  • 4,178
4 votes

Sizeof variables and Due's RAM

The sizeof operator's result is number of bytes, not number of array elements. Your arrays in the program above have two bytes per element, hence twice as many bytes as elements. If you want to ...
James Waldby - jwpat7's user avatar
4 votes
Accepted

L and ON keeps blinking

You should split your problem in pieces. Like you cannot get communication with your Arduino again, so check first: If you plug in the Arduino / USB, do you get a message on your computer? Is it ...
Michel Keijzers's user avatar
4 votes

How to connect Arduino 5v pin with multiple things?

The simplest way is to just use a breadboard to connect your devices to your Arduino: I can't read Chinese, so I can't check the specifications of these particular devices, but you need to be aware ...
sempaiscuba's user avatar
  • 1,032
4 votes
Accepted

Digital Pins reads 1 when configured with internal_pullup

There is no difference between a switch and a "pin" for input. All are either HIGH or LOW. You tie it HIGH with the pullup, and then try giving it a HIGH with +5V (Caution: The Due is a 3.3V device, ...
Majenko's user avatar
  • 105k
4 votes

USB reset fails on arduino due because of 5v on digital pins

You're over-stressing the MCU and causing all sorts of horrible things to happen with the power rails. Of course nasty things are going to happen. The only way to fix it is to change the circuitry. ...
Majenko's user avatar
  • 105k
4 votes

How to package a 16 bit integer to send it with serial.write?

Send the 16-bit value as two 8-bit values (with a start byte as per JRobert's answer): Serial.write(0xCC); // Send the start byte Serial.write((sensorVal >> 8) & 0xFF); // Send the upper ...
Tom's user avatar
  • 226
4 votes
Accepted

Serial.availableForWrite versus Serial.flush

The line while (Serial.availableForWrite() <= 0) {} waits until the serial output buffer is not full. Whereas Serial.flush(); waits until the serial output buffer is empty.
Edgar Bonet's user avatar
  • 43.2k
4 votes

SPI Slave Programming for Arduino

SPI.h library by default only support Master mode, the SPI.begin() will automatically set slave select (ss) pin to HIGH whether you have pinMode(ss, OUTPUT) in your setup() code or not and set the ...
hcheung's user avatar
  • 1,381
4 votes
Accepted

How do I get the size of my program at runtime?

Just to warn you, I minimally tested this, but it seems to work. In the Due's linker script there are these relevant lines, containing the named rom section. MEMORY { rom (rx) : ORIGIN = ...
timemage's user avatar
  • 5,299
3 votes

Has anyone modified a 16x2 LCD shield to work with Arduino DUE?

I understand this is an 8yo thread, however my answer might still help someone. I connected an unmodified no-brand LCD Shield to an Arduino DUE and it works perfectly - the only thing I had to change ...
Marco Brembati's user avatar
3 votes
Accepted

Employing C++ code for Arduino

You've got quite an interesting project. Programming an Arduino (C++) Arduino is C++ (or atleast a subset). The Arduino IDE uses the GNU AVR-GCC compiler. And it takes care of all "make" files and ...
aaa's user avatar
  • 2,695
3 votes

Unable to upload to Arduino Due using version 1.6.8 of SAM tools; bossac.exe throwing an error

I finally figured out the problem. This occurred on both a Mac and PC (Windows 10). This error occurred because of the true after the -w switch. To fix it I modified the package to tell the IDE not ...
Tim's user avatar
  • 51
3 votes
Accepted

Syncing/taking external clock for SPI on Arduino Due

For your external source to be an SPI bus master, it has to be the only one generating the clock signal. Yet, calling SPI.transfer() also generates a clock signal from the Arduino; both devices are ...
SoreDakeNoKoto's user avatar

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