简体   繁体   中英

How to do Led blink with each port, using stm32 (stm32f103c8t6) boards and Adruino

I am completely new to this and willing to do a simple task using stm32f103c8t6 board, which is "led blink".

Using ArduinoIDE and a simple circuit as shown in the picture, everything goes fine on port PC13. but as soon as I try other ports, it doesn't work. My aim is to be able to toggle the led status using ports PA0 to PA5.

Here is my code:

void setup() {
  // initialize the digital pin as an output.
  pinMode(PC13, OUTPUT);
}

void loop() {
  digitalWrite(PC13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(PC13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

I change PC13 to PA0, and rewire the board, but no luck :(

How can I solve this issue. Any kind of help is highly appreciated.

在此处输入图片说明

You are using an external LED right (it's a bit difficult to tell for sure in your photo)? The "blue pill"'s internal LED is tied to PC13 only. If you are using an external LED and the program with PC13 works, then there should not be any issue with PA0 to PA5. The only thing I can think of currently is that somehow your program is not being flashed correctly so it's still running the old code.

To test this theory, start with the working PC13 program and then modify the delay time to 2 secs or whatever. Then you can be sure that the new program is downloaded correctly.

Sorry for the stupid question. My problem was that I had a broken wire,and when I changed it, everything was working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM