arduino / arduino/ArduinoCore-avr
Use named pins for Digital pins (D0-D22)
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
This is my first request and I think it would be easy to implement with full backward compatibility. Due to the fact arduino IDE is being used to program a wider range of hardware as time goes by, I think it would be pretty convenient to add some defines to the pins_arduino.h files in the hardware variants folders. This way sketches could use not only the number relative to a digital pin but also a named pin, most in the way analog pins are defined. In my tests, simply adding the following defines makes the command
digitalWrite(6,HIGH) and digitalWrite(D6,HIGH) compile and run correctly. Other hardware, like ESP-12 and WEMOS include this definitions in their pins_arduino.h header files; so including them into the standard headers will make programming more straight forward among platforms.
`
#define D0 (0)
#define D1 (1)
#define D2 (2)
#define D3 (3)
#define D4 (4)
#define D5 (5)
#define D6 (6)
#define D7 (7)
#define D8 (8)
#define D9 (9)
#define D10 (10)
#define D11 (11)
#define D12 (12)
#define D13 (13)
#define D14 (14)
#define D15 (15)
#define D16 (16)
#define D17 (17)
#define D18 (18)
#define D19 (19)
#define D20 (20)
#define D21 (21)
#define D22 (22)
`
Main advantage of doing this manner is that the code will run with minnor changes through a MCU change (Arduino UNO, WEMOS D1R2, NodeMCU primerly). As preprocessor directives, their impact in the memory use and performance should be almost zero.
I can do this manually by myself but in each update it's lost.
Thanks for the attention.
Carlos
PD. I do my best with my English. Sorry for the mispels
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the pins_arduino.h files in the hardware variants folders and compare how ESP-12 and WEMOS define named digital pins. Check representative Arduino sketches using digitalWrite with numeric pins, then confirm that equivalent D0-D22 names compile and preserve existing behavior across the supported AVR variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100