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,...
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....
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 ...
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). ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
5
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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. ...
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 ...
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.
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 = ...
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 ...
3
votes
Accepted
What is the proper way to implement PID?
Each unique variable you want control over should have a single pid loop, and each loop should only ever stretch across one "order" of time.
For example, to control the craft's roll rate, you should ...
3
votes
How to save a hex file into Arduino Flash to send it via Serial?
If I understand your question correctly, you need to integrate this data into a .ino script. Probably as a byte array. Then the script can read the array and Serial.write its content.
You could ...
3
votes
Accepted
Fastest communication between Arduino and PC
Switch to using SerialUSB instead and use the other USB port. The baud rate is meaningless then - it runs at the speed of the USB port, which is a lot faster than serial (Linux reports it as 480Mbps, ...
3
votes
Accepted
Persistence of user input after reboot
Better than that: Zero wires.
The Arduino has EEPROM built in.
3
votes
Accepted
How to choose SDA/SCL pair on Arduino Due?
Pins 20 and 21 are the default I2C pins. A lot of libraries assume you use these, and would require some extra work to get working with SDA1/SCL1.
They also have their pullup resistors already ...
3
votes
Library to set internal analog gain of the Arduino?
I would recommend you to check Nick Gammon's example on using the analog comparator by means of configuring the relevant flag bits of registers in the ATmega328. Sample code from the link, by Nick:
...
3
votes
PCA9685: how "unset" PWM signal?
You can try to send no "ON" time to your output pin on the PCA9685.
So, you start the "ON" at 0 and stop the "OFF" at 0.
void freeServo(uint8_t servoIdx)
{
pwm.setPWM(...
3
votes
Why would digital outputs on Arduino Due be less than 3.3V?
The output impedance for the MCU used in the Due is about 46ohm. Along with the relay's impedance this forms a voltage divider that results in a final voltage that is lower than the unloaded voltage ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arduino-due × 461serial × 54
arduino-uno × 34
spi × 30
programming × 22
arduino-mega × 21
interrupt × 19
usb × 17
arduino-ide × 16
sensors × 16
power × 15
i2c × 15
c++ × 14
shields × 14
adc × 12
arduino-nano × 10
timers × 10
communication × 10
sd-card × 10
flash × 10
pins × 9
uart × 9
pwm × 8
c × 8
analogread × 8