Hi, I'm testing a sketch that uses a potentiometer to control the speed of a blinking LED with an stm32 bluepill, but my LED isn't turning on. I've connected by A0 pin to the potentiometer and my B6 pin to the LED. Here's the circuit. (Sorry the wires are weird, I ran out of red and black) I'm using this diagram, but with A0 instead of A2 and B6 instead of D4.
Here's the code:
int potPin = PA0;
int ledPin = PB6;
int val=0;
void setup() {
pinMode (ledPin, OUTPUT);//Sets the LED pin as an output
}
void loop() {
val = analogRead(potPin); //reads the analogue voltage from the pot via ADC and stores it in the variable
digitalWrite(ledPin, HIGH); //turn the LED output pin high turning the LED on
delay(val); //waits an amount of time dependent on the potentiometer position
digitalWrite(ledPin, LOW); //turn the LED output pin low turning the LED off
delay(val); //waits an amount of time dependent on the potentiometer position
}
Let me know if you need more info!