I just bought an Arduino Pro Micro (atmega32u4) and a ELEGOO Unu R3 starter kit so I'm admittedly very new to writing code for arduino. I had used the IDE for configuring and Compiling Marlin for my 3D printers but this is my first personal project.
I am trying to add buttons to this code that I know was converted to C at some point based on the comments if you follow the forks back far enough. The Base code takes reverse engineered Controller code to Create a Switch compatible button library for macros.
At first I thought I could use
#define buttonOne 6
bool buttonOneState;
pinMode(buttonOne, INPUT_PULLUP);
with
buttonOneState = digitalRead(buttonOne);
In the loop I wanted it to check but this fails to compile saying
src/wildareabreeding.c:149:9: note: in expansion of macro 'buttonOne'
pinMode(buttonOne, INPUT_PULLUP);
^
src/wildareabreeding.c:149:20: error: unknown type name 'INPUT_PULLUP'
pinMode(buttonOne, INPUT_PULLUP);
I have been compiling through Git Bash with this line as instructed from the original code
C:\Users\Dracrius\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Dracrius\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM7 -b57600 -D -Uflash:w:D:\pkmn-swsh-automation-tools-master\pkmn-swsh-automation-tools\wildareabreeding.hex:i
Maybe I'm missing a reference but deep down I thought it was because the code is in C and those only work in the IDE but then after some research the IDE is using C so maybe I'm missing something really small because the only other thing I've been able to find is one fork of this code does have buttons but they use bit operators and directly reference things which seems miles over my head. I understand most of it but idk how to find all the refrences for my arduino and the bits to pin matchup. Also I can't for the life of me find out how you use the internal Pullup resistors with that method. The page refrencing it here mentions you can do it in code but not how to do it!
This is what the other method from the other fork looks like. I have no idea what the whole commented out part is about and I can't tell if they are using the internal pullup resistors. The githubs instructions and wiring diagram make no mention of resistors (not even for the led so that spikes concern). The source is here!
uint8_t PushButton_D0(void) {
//return 1; !(uint8_t)(PINB & _BV(PB6));
//static uint8_t btn = _BV(PB6);
//uint8_t t = PINB; // read port status
DDRD &= ~(1<<PD0);
PORTD |= (1<<PD0);
if (! (PIND & (1<<PD0))){
return 0;
} else {
return 1;
}
}
And Finally I will link to the modifications I tried to make in full on Pastbin
Thank you in advanced any help or guidance is much appreciated!