Hey all, apologies if this isn't the place to post this, but I'm running into some issues with programming an Arduino Uno with VSCode. My reason for using VSCode rather than the Arduino IDE is that I'm more accustomed to using a main function rather than setup and loop, and would prefer not to use the latter.
#include <Arduino.h>
int main(){
pinMode(LED_BUILTIN, OUTPUT);
while (true){
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
}
When I upload the above code, the Arduino essentially only turns the LED on. If I reverse the order, i.e. low to high rather than high to low, it turns the LED off. Is this an issue with how I'm configuring this, or an issue with the VSCode extension, or something else?
EDIT: I am an idiot and didn't realize that init() was needed before doing anything within main. If anyone wants to explain what exactly init() does to prevent the code being essentially locked on that first line after the while(true), I'd appreciate that. For anyone who's curious, this is my current code after fixing my mistake:
#include <Arduino.h>
int main(){
init();
pinMode(LED_BUILTIN, OUTPUT);
while (true){
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
}