Just started messing around with Arduino for the first time and was following these sample projects
Everything has been working great until I got to this code:
int potpin = 0; // initialize analog pin 0
int ledpin = 11; //initialize digital pin 11(PWM output)
int val = 0; // Temporarily store variables' value from the sensor
void setup() {
pinMode(ledpin, OUTPUT); // define digital pin 11 as “output”
Serial.begin(9600); // set baud rate at 9600
// attention: for analog ports, they are automatically set up as “input”
}
void loop() {
val = analogRead(potpin); // read the analog value from the sensor and assign it to val
Serial.println(val); // display value of val
analogWrite(ledpin, val / 4); // turn on LED and set up brightness(maximum output of PWM is 255)
delay(10); // wait for 0.01 second
}
When I Upload and Monitor this the first time, the program works as expected. However, when I try and Upload another program (simple Hello World to reset), VSCode / PlatformIO cannot detect the Port anymore. It is isnt until I upload a program from the official Arduino Cloud IDE that it begins to work again.
Is there a setting that I am missing that is preventing this from working, or something specific with this code?