Go Down

Topic: Arduino Due libraries (official and 3rd party) (Read 302276 times) previous topic - next topic


Apr 14, 2014, 11:49 am Last Edit: Apr 14, 2014, 01:20 pm by TexArduino Reason: 1
AccelStepper.h for stepper control of position, speed and acceleration:


DueFlashStorage for the use of flash memory, read and write:


UTFT.h for display lcd, tested with 7" display cte70:
WARNING: the functions with RGB on the parameters reverse the R with B so it uses BGR. So to solve the problem you have to modify the library function. Remember that the rgb color are saved in a word build like that
so use this code for the reversing

Code: [Select]

temp1=( (col>>8) & 0x07) | ( ( (col & 0xff) & 0x1f)<<3);
temp2=( (col & 0xff) & 0xE0) | ( ( (col>>8) &  0xf8)>>3);

then unificate temp1 and temp2 in a single word


UTouch.h for control of a touch screen.
NOTE: pins used are "Clock,Chip Select,Digital in,Digital out,Irq"



I modified the SimpleModbusSlave lib found at :
... to work on DUE. One can user hardware USART 0,1,2.

I also added a _fonc option , the SimpleModbusSlave_DUE_fonc, so one can do something in the main sketch BEFORE response (useful to compute value of regs). A 2nd fonction is  to update some sketch variables form 1 master global order.


The final release of the Entropy library, which provides a source of true, cryptographically secure, random numbers on most Arduino platforms, including the UNO, MEGA, Teensy, and Due. 

This final release builds upon the earlier beta releases methods for providing various types of random integers to now also provide random floats, as well as a new method to provide random floats with a gaussian distribution.  All other methods use a uniform distribution, where each possible value has an equal chance of occurring, while the gaussian distribution allows you to specify a mean (average) value and a standard deviation.  This will then produce a series of random floats that would demonstrate those characteristic values if analyzed.  If graphed they would display the typical 'bell curve'.  This new method is most useful for certain types of simulations.  On the AVR based Arduino's as well as the Teensy boards, the library uses timer jitter as the source of the random numbers; however, on the Due it uses the internal hardware random number generator. 

The complete source, along with tests and test results for the library is available from the Google Code depository <http://code.google.com/p/avr-hardware-random-number-generation/>.  For those who just want the library to use, it is available for download from the libraries web page <https://sites.google.com/site/astudyofentropy/project-definition/timer-jitter-entropy-sources/entropy-library>.


Jun 04, 2014, 12:01 am Last Edit: Jun 04, 2014, 09:43 am by hbierau Reason: 1
I have successfully tested this Button Library:


It is indeed a very handy library featuring multiple button instances, with pull-up option, debouncing, it distinguishes between pressing shortly and holding the button pressed, etc.  


I've incorporated the existing work by Collin Kidder and Daniel Kasamis on due_can into a "unified" CAN library.  One simple API gets you functionality for three different types of CAN controller; Microchip MCP2515, Atmel SAM3X (Due), and Freescale K2x (Teensy 3.1). It's not quite finished yet, but if you are interested in using it, take a look at https://github.com/McNeight/CAN-Library/

Comments and patches are more than welcome.



I have the same problem with libraries, but my error is avr/sleep.h:no such file... I get this error when i try to compile BLE Shield example for Arduino Due. Any solution..? Thanks for reply.


Library:  pwm01.h
Description:  A clean alternate approach for setting up unique PWM frequencies from within a sketch, for any or all PWM pins.  The trick is to utilize the two PWM clocks (CLKA & CLKB) provided by the SAM3X8E chip.

I wrote and enclosed a library (pwm01.h).  It includes 4 user functions to:  1) setup PWM resolution, 2) setup PWM pin, frequency & pick clock, 3) write duty cycle, and 4) stop PWM.  See example code for usage:

Code: [Select]
#include "C:\Programs\arduino-1.5.1r2\hardware\arduino\sam\libraries\Pwm01\pwm01.h"

void setup()
   uint32_t  pwm_duty = 32767;
   uint32_t  pwm_freq1 = 2;  
   uint32_t  pwm_freq2 = 5000;

   // Set PWM Resolution

   // Setup PWM Once (Up to two unique frequencies allowed
   pwm_setup( 6, pwm_freq1, 1);  // Pin 6 freq set to "pwm_freq1" on clock A
   pwm_setup( 7, pwm_freq2, 2);  // Pin 7 freq set to "pwm_freq2" on clock B
   pwm_setup( 8, pwm_freq2, 2);  // Pin 8 freq set to "pwm_freq2" on clock B
   pwm_setup( 9, pwm_freq2, 2);  // Pin 9 freq set to "pwm_freq2" on clock B
   // Write PWM Duty Cycle Anytime After PWM Setup
   pwm_write_duty( 6, pwm_duty );  // 50% duty cycle on Pin 6
   pwm_write_duty( 7, pwm_duty );  // 50% duty cycle on Pin 7
   pwm_write_duty( 8, pwm_duty );  // 50% duty cycle on Pin 8
   pwm_write_duty( 9, pwm_duty );  // 50% duty cycle on Pin 9

   delay(30000);  // 30sec Delay; PWM signal will still stream
   // Force PWM Stop On All Pins
   pwm_stop( 6 );
   pwm_stop( 7 );
   pwm_stop( 8 );
   pwm_stop( 9 );

void loop()

The pwm01.h library and example code were tested in IDE 1.5.1r2.  Additional notes on this library:
- Applies to Arduino-Due board, PWM pins 6, 7, 8 & 9.
- Libary Does not operate on the TIO pins.
- Unique frequencies set via PWM Clock-A ("CLKA") and Clock-B ("CLKB")
 Therefore, up to two unique frequencies allowed.
- Set max duty cycle counts (pwm_max_duty_Ncount) equal to 255 per Arduino approach.  
 This value is best SUITED for low frequency applications (2hz to 40,000hz) such as
 PWM motor drivers, 38khz infrared transmitters, etc.
- Future library versions will address high frequency applications.
- Arduino's "wiring_analog.c" function was very helpful in this effort.


Probably a stupid question but where can I find this pwm01.h library?


The library is linked at the bottom of the post that you quoted.

Look for this -  pwm01.h (3.96 KB - downloaded 338 times.)



Has anyone got the due working with SDI-12 library that is made available by stroudcenter. Github repo is:

I tried working with the SDI12 lib and due but ended up with the following error message:

home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp: In member function 'void SDI12::setState(uint8_t)':
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:377:32: error: 'digitalPinToPCMSK' was not declared in this scope
     *digitalPinToPCMSK(_dataPin) &= ~(1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:377:71: error: 'digitalPinToPCMSKbit' was not declared in this scope
     *digitalPinToPCMSK(_dataPin) &= ~(1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:389:29: error: 'digitalPinToPCICR' was not declared in this scope
  *digitalPinToPCICR(_dataPin) |= (1<<digitalPinToPCICRbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:389:67: error: 'digitalPinToPCICRbit' was not declared in this scope
  *digitalPinToPCICR(_dataPin) |= (1<<digitalPinToPCICRbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:390:32: error: 'digitalPinToPCMSK' was not declared in this scope
     *digitalPinToPCMSK(_dataPin) |= (1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:390:70: error: 'digitalPinToPCMSKbit' was not declared in this scope
     *digitalPinToPCMSK(_dataPin) |= (1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:394:31: error: 'digitalPinToPCMSK' was not declared in this scope
    *digitalPinToPCMSK(_dataPin) &= ~(1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:394:70: error: 'digitalPinToPCMSKbit' was not declared in this scope
    *digitalPinToPCMSK(_dataPin) &= ~(1<<digitalPinToPCMSKbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:396:32: error: 'digitalPinToPCICR' was not declared in this scope
     *digitalPinToPCICR(_dataPin) &= ~(1<<digitalPinToPCICRbit(_dataPin));
/home/bmubuntu/Arduino/libraries/Arduino-SDI-12-master/SDI12.cpp:396:71: error: 'digitalPinToPCICRbit' was not declared in this scope
     *digitalPinToPCICR(_dataPin) &= ~(1<<digitalPinToPCICRbit(_dataPin));

Sorry that i have to post it again here on the due forum.

I am using arduino-1.5.7.

Please help me in this regard.



I have just installed the Arduino DUE 1.5.8 Windows library from the zipfile so that I can use a microSD card on an Arduino Ethernet shield. However, despite there being an SD.h file in the zipfile it has not been installed in the "contributed" library - the only option offered in UECIDE - so when I try to compile my SD card sketch it fails because the #include <SD.h> statement is rejected. Can anyone tell me what I should do?


RFM73 transceiver library now ported to the DUE, please consider there may be some tweaking/cleaning to be done but at least everyone can have something to play with.


I recently had a need to use a Due as a web server.  I started with the excellent application posted here:


While it worked fine, it was not structured as a library, and parts were too hard-coded.  I did a bunch of mods, turned it into a library, and defined a few "helper" classes to implement a symbol table (for putting "live" data into the HTML on-the-fly), and for simplifying the content creation.  It currently supports GET and POST events, and will handle HTML, CSS, JPG, GIF and PNG data.  All content is addressed by virtual file paths.  While I did not carry forward the SD-card filesystem used in the original code (I don't have SD), it would be easy to add that back in.

All HTML and CSS source code and images are in the HTML subdirectory of the test application.  A Perl script, HTMLConvert.pl, i used to convert the content into c char arrays that get compiled into the application.

To try it out, just un-zip the archive to your local library directory, set the desired IP address near the top of the WebServerTest.ino or enable DHCP, then load it an go.  Point your browser to the default (hard) IP address application, compile and run.  Point your browser at that IP address, and it should all work.


Ray L.


Serial library using DMA. Needs more testing, as far I can tell though it works.



Serial library using DMA. Needs more testing, as far I can tell though it works.

Looks good. Really clean code. Good comments at the head of each function.

But what does it do? What are the limitations? Does it clobber any Arduino constructs, like can I use the same UART with both methods interchangeabley? A readme file would be very useful.

Any example code? It looks like the constructor requires a pointer to a UART but I don't know what that might look like.
"The problem is in the code you didn't post."

Go Up