What is the correct board type to use for the D21G Proto within the Arduino programming environment?
In one post you said to use Arduino Zero (blynk). On your web link at https://github.com/Industruino/libraries,
it says to install Industruino board type and select it (Industruino D21G). I'm getting compiler errors with pin mapping using your board definition with other SAMD21 libs.
For instance, try this example: http://www.avdweb.nl/arduino/libraries/samd21-timer.html
- configuring the timers with a callback interrupt
Load and compile this file:
Note: The avdweb_SAMDtimer lib uses Adafruit_ZeroTimer lib to accomplish the above task.
It will compile using board type Arduino/Genuino Zero (programming port), but has pin errors with Industruino D21G.
Even for the A0/DAC0 output, your definition requires DAC0 be used versus A0.
What am I missing?
The Industruino D21G is using the same ATSAMD21G18 MCU as the Arduino Zero, with minor differences in the pin allocation.
So it is part of the Arduino Zero family, but has its own board definition inside the Arduino IDE. Most Arduino libraries (general, and specific Arduino Zero) will run out of the box, some may require minor modifications. Always compile for Industruino D21G.
The example you mention (SAMDtimer) can be made to work with a small modification in the Adafruit_ZeroTimer.cpp file:
- in line 31, change pin 12 to pin 0 (the Industruino D21G has timer 3 on D0 instead of D12)
- comment out 4 lines 45-49 (the Industruino D21G does not use pin A1)
- in line 56, change pin A2 to pin 6 (the Industruino D21G does not use A2 and has timer 4 on D6)
Now you can use the SAMDtimer_examples sketch as follows:
- timer3 with interrupt and with output on D0 (if you do not use it for Serial)
- timer4 with interrupt and with output on D6
- timer5 with interrupt
Example of constructors for that avdweb_SAMDtimer library:
- SAMDtimer timer3_10Hz = SAMDtimer(3, ISR_timer3_LED1 , 1e5); // timer 3 with 10Hz interrupt
- SAMDtimer timer3_1Hz = SAMDtimer(3, TC_COUNTER_SIZE_16BIT, 0, 1e6, 9e5); // timer 3 on D0 with 1Hz, pulse width 0.9s
- SAMDtimer timer4_2Hz = SAMDtimer(4, TC_COUNTER_SIZE_16BIT, 6, 5e5, 1e5); // timer 4 on D6 with 2Hz, pulse width 20%
- SAMDtimer timer5_1Hz = SAMDtimer(5, ISR_timer5_LED2 , 1e6); // timer 5 with 1Hz interrupt
I have only done simple tests with this, please let us know if you encounter any problems.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!