2

I am using a BBC Micro:bit version 2 and have a program set up on an editor called Micro:blocks. The code is supposed to take input from the first micro:bit's microphone and play it out of the other one's speaker. But when I try it, all I get is an annoying buzzing noise coming out the other end. I can play it correctly out of the first micro:bit only (not using radio) and it sounds fine. I can't figure out why the second micro:bit makes a buzzing noise.

With the program without radio, I messed around with how long before it played the noise, and none of the tests resulted in a buzzing noise, so I know it's probably not a timing or delay issue.

Anyways, here is my code.

Transmitting code:

when [button a] pressed
  set radio group to (7)
  set radio channel to (7)
  set radio transmit power to (7)
  digital pin write (on) to (28)
  forever
     analog pin write (microphone + 500) to (0)
     radio transmit number (microphone + 500)


when [button b] pressed
   stop other processes
   radio transmit number (0)
   analog pin write (0) to (0)

receiving code:

when program started
   forever
      if (new radio message)
         analog pin write (0) to (radio last received number)

1 Answers1

0

This is an interesting project!

Your program looks correct but the radio system may not be fast enough to send each sound sample as a separate message. As a result, you are just hearing a series of clicks, resulting in the buzzing noise.

You could check that the sound data is being sent and received by sending a second or two of sound and graphing the incoming samples on the receiving side. It will be slow, but you should see something that looks like a smooth audio waveform.

Assuming speed is the issue, you could try sending several samples in each packet by encoding them into a string. But even that may not be fast enough to create a smooth audio stream, especially since the encode/decode process will take time.

A different approach would be for the receiver to collect a second or two of sound samples in a list, then play them back in a burst. That would not provide continuous audio but might allow transmitting a sentence at a time.

Here is a record/playback project you might use as a starting point for experimentation.

enter image description here

Note that you can download this image and drop the .png file into the MicroBlocks IDE. MicroBlocks will read the project back from the image itself :)

Bernat Romagosa
  • 1,172
  • 9
  • 15