Skip to main content
Explorer
August 16, 2024
Solved

Issue with a black pill board programmed via the Arduino IDE

  • August 16, 2024
  • 3 replies
  • 2441 views

Hello, all. I am currently trying to program a black pill board to print out the output from a sound sensor, for which I use the Arduino IDE 2.3.2. 

Used components:

- STM32F411CEU6 black pill
- KY-037 sound sensor

Current connections:

- the "G" pin from the sensor is connected to the "GND" pin on the black pill
- the "+" pin from the sensor is connected to the "3v3" pin on the black pill
- the "A0" pin from the sensor is connected to the "A9" pin on the black pill

The code:

 

 

#define DIGITAL_INPUT PA9

void setup() {
 Serial.begin(9600);
 pinMode(DIGITAL_INPUT, INPUT);
}

void loop() {
 Serial.println(analogRead(DIGITAL_INPUT));
}

 

 

This code prints out values around 270-290 and it doesn't seem like creating any loud noises has any effect on the output, and neither does changing the potentiometer on the sensor itself. What I am trying to get is an output that has a clear and visible change between different amounts of noise. I am starting to think that the current output is just the floating value of the "A9" pin.

Other relevant info:

- I believe the problem isn't in the black pill itself, since I can successfully implement a simple "blink" functionality.
- I have already adjusted the potentiometer on the sensor so that the L2 is off. It turns on briefly when it detects a noise (such as clapping or anything louder).
- Changing the pin from "A9" outputs values from different ranges, but those values still don't seem to be affected by any noise, no matter how loud.
- The values don't change if "A9" is connected to the "A0" pin on the sensor instead of "D0".

If anyone can offer some assistance, I would majorly appreciate it.

    This topic has been closed for replies.
    Best answer by robotics_beginner

    I double-checked the contact on the black pill pins and it seems that it fixed the issue. Apparently the contacts on all the pins were a bit weak, so I reinforced them a bit and now I am getting an actual output. Now I get values around 690 in silence, with different jumps in value depending on the sounds I make. I can't believe it was such a trivial thing afterall.

    I appreciate you all helping me out and I wish you the best of luck in your future endeavors. Have a great day!

    3 replies

    Explorer
    August 16, 2024

    Quick correction for the last point in other relevant info. The values don't change if "A9" is connected to the "D0" pin on the sensor instead of "A0".

    Graduate II
    August 17, 2024

    The sensors seems to.give high or low. So  you should not use analog read.  Chek with a multimeter if the output changes.      https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/

    Explorer
    August 17, 2024

    What do you mean "high or low"? The sensor has both an analog output pin and a digital one. If I use digitalRead, I just get a constant output of "0", even when I can clearly see that L2 is on.

    Explorer II
    August 17, 2024

    Hi , you need to use an analog pin

    Explorer
    August 17, 2024

    I already am. Is A9 not analog?

    Explorer II
    August 17, 2024

    @robotics_beginner wrote:

    I already am. Is A9 not analog?


    https://stm32world.com/wiki/Black_Pill 

    robotics_beginnerAuthorAnswer
    Explorer
    August 17, 2024

    I double-checked the contact on the black pill pins and it seems that it fixed the issue. Apparently the contacts on all the pins were a bit weak, so I reinforced them a bit and now I am getting an actual output. Now I get values around 690 in silence, with different jumps in value depending on the sounds I make. I can't believe it was such a trivial thing afterall.

    I appreciate you all helping me out and I wish you the best of luck in your future endeavors. Have a great day!