What pin definitions do I use for a Trinket M0 when coding w

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
romsk
 
Posts: 37
Joined: Sat Feb 23, 2019 5:01 pm

What pin definitions do I use for a Trinket M0 when coding w

Post by romsk »

I have done some searching but I could not find out how the Trinket M0 pins are defined when using the Arduino IDE.

For example:
The pin labeled "0" on the Trinket M0 is referred to as board.D0 in Circuit Python, how do I refer to that pin in the Arduino IDE C/C++ code?

Is it simply 0 as we do for the Rx<-0 pin on the Arduino UNO.

Where can I find a list of ALL these definitions? I have found many nice pin-out drawings of the Trinket M0, but because each pin can be configured for different functions, there are several names listed for each pin - so it is hard to figure which definition is used in the C/C++ code.

Trinket M0:
0 is defined as ?
~1 is defined as ? Does this have different definitions in code if I use that pin for I/O vs. Analog Out?
2 is defined as ?
3 is defined as ?
4 is defined as ?

Thanks

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: What pin definitions do I use for a Trinket M0 when codi

Post by dastels »


User avatar
romsk
 
Posts: 37
Joined: Sat Feb 23, 2019 5:01 pm

Re: What pin definitions do I use for a Trinket M0 when codi

Post by romsk »

Dave,
Thanks, I did see that page, it makes it clear if I want to use, say, pin 1~ as an analog pin, I use "A0" but to use it as a digital pin, it only says "Digital # 1" which is not quite the names I see in the pin out drawing.

Update:
I do see dark green names that the legend says are Arduino Names. So I guess that is what I am looking for.

Thanks!



The following is now moot:
I have tried Digital#1 and all sorts of permutations. The pin out drawing is very informative, but nothing that definitively states:
"When coding with the Arduino IDE, Digital # 1 pin is called "?????" In the code.

See what I mean, they give us clues and SAM device pins are called everything under the sun because of their various functions, including how they are labeled on boards does not match what we use in code.

I will look at that color pin out drawing again, but it is still confusing which "pin name" I use in the code.

Could you give me a code snippet on, say, how to output a high on the Digital # 1 pin which is called 1~ on the Trinket M0 - yes, I get the Tilda means true analog output, so I would call it pin A0, but what do I call it as a Digital pin?

Thanks
Last edited by romsk on Sat Aug 06, 2022 9:32 pm, edited 1 time in total.

User avatar
romsk
 
Posts: 37
Joined: Sat Feb 23, 2019 5:01 pm

Re: What pin definitions do I use for a Trinket M0 when codi

Post by romsk »

Ok,
I am going to try this:
Thanks!

Code: Select all

#if TARGET_BOARD == TARGET_BOARD_ARDUINO_UNO_R3

#define USER_LED_PIN                     13 /* Arduino UNO R3 Yellow 'L' LED */
#define ALDL_160_BAUD_PIN                 2 /* Arduino UNO R3 'DIGITAL – PWM~ (IOL)' Pin  2: Digtial Input from a 5.0V Zener limiter from the Fiero ALDL Connector 160 Baud Pin (ALDL Pin E) */
#define ALDL_SES_PIN                      4 /* Arduino UNO R3 'DIGITAL – PWM~ (IOL)' Pin  4: Digital Input from a 5.0V Zener limiter from the Fiero ALDL Connector SES Signal (ALDL Pin D) */
#define ALDL_DIAG_MODE_SELECT_PIN         3 /* Arduino UNO R3 'DIGITAL – PWM~ (IOL)' Pin ~3: PWM Output to a Transisitor to control the resistance to the Fiero ALDL Connector Diag Mode Select Pin (ALDL Pin B) */
                                            /*
                                             *  The Arduino UNO R3 does not have a Digital to Analog Converter (DAC) output pin, so a PWM pin is used to generate continous PWM
                                             *  pulses out of the pin, therefore, the transistor has a simple Resistor-Capacitor (RC) Low Pass Filter before its Base input to
                                             *  convert the PWM stream to a steady analog DC voltage (effectively acting like a DAC).  
                                             */
                                             
#elif TARGET_BOARD == TARGET_BOARD_ADAFRUIT_TRINKET_M0

#define USER_LED_PIN                     13 /* Adafruit Trinket M0 Red LED */
#define ALDL_160_BAUD_PIN                 0 /* Adafruit Trinket M0 Pin  0: Digtial Input from a 3.3V Zener limiter from the Fiero ALDL Connector 160 Baud Pin (ALDL Pin E) */
#define ALDL_SES_PIN                      2 /* Adafruit Trinket M0 Pin  2: Digital Input from a 3.3V Zener limiter from the Fiero ALDL Connector SES Signal (ALDL Pin D) */
#define ALDL_DIAG_MODE_SELECT_PIN        A0 /* Adafruit Trinket M0 Pin ~1: 12 Bit DAC Output to a Transistor to control the resistance to the Fiero ALDL Connector Diag Mode Select Pin (ALDL Pin B) */
                                            /*
                                             *  The Adafruit Trinket M0 has a 12-bit Digital to Analog Converter (DAC) output pin, so there is no need for a simple
                                             *  Resistor-Capacitor (RC) Low Pass Filter before the Base input of the Transistor.  
                                             */
                                             
#endif

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: What pin definitions do I use for a Trinket M0 when codi

Post by dastels »

Yes, you want the "Arduino name" labels for the pins.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”