Make a wish

If you have any wishes for tutorials feel free to write it in the comments and I try to write about it 🙂

4 Responses

  1. i want the buzzer integrate with ultrasonic sensor. if the obstacle is approaching the system the buzzer should beep loudly and if the buzzer is going away buzzer sound should be fade
    any help would be thankful

    • This should not be that hard. For example, play a soundfile with aplay and change the volume, depending on the distance:

      import os
      MIN_DIST = 10 # in cm, set volume = 100%
      MAX_DIST = 150 # in cm, set volume = 0%
      dist = ... # measure the distance
      volume = ((dist - MIN_DIST) / float(MAX_DIST - MIN_DIST)) # normalize
      volume = int(100 - min(0, max(100, volume))) # map to bounds [0,100]
      os.system("sudo amixer set PCM --" + str(volume) + "%") # set volume

      I hope this will help you.


Leave a Comment

Your email address will not be published.