[idea] Garage parking assistance

Used Grove Moduls :

  • Ultrasonic Ranger
  • Speaker
  • LED Strip
    and Raspberry Pi as Wio Server

Python Script:

import requests
import time

if __name__ == '__main__':

    url_range = 'http://192.168.38.58:8080/v1/node/GroveUltraRangerD1/range_in_cm?access_token=9164e46e6c460b57b711ac90eca626b9'
    
    response = requests.get(url_range)
    
    range_cm = response.json()['range_cm']
    leds = int(0)
    
    while range_cm > 5 :
        
        leds_old = leds
        leds = int(range_cm / 10)
        
        if leds > 20 : 
            leds = 20
        
        if leds <> leds_old :
            rgb = ''
            rgbs = int(0)

            while rgbs < 20 :
                rgbs += 1
                
                if rgbs <= leds :
                    if leds < 5 :
                        rgb += '110000'
                    else :
                        rgb += '001100'
                else :
                    rgb += '000000'
            
            url_leds = 'http://192.168.38.58:8080/v1/node/GroveLedWs2812D0/segment/0/' + rgb + '?access_token=9164e46e6c460b57b711ac90eca626b9'
            requests.post(url_leds)

        print(range_cm, leds)
   
        if leds < 2 :
            url_beep = 'http://192.168.38.58:8080/v1/node/GroveSpeakerD2/sound_ms/1000/200?access_token=9164e46e6c460b57b711ac90eca626b9'
            requests.post(url_beep)
        elif leds < 3 :
            url_beep = 'http://192.168.38.58:8080/v1/node/GroveSpeakerD2/sound_ms/800/200?access_token=9164e46e6c460b57b711ac90eca626b9'
            requests.post(url_beep)
        elif leds < 4 :
            url_beep = 'http://192.168.38.58:8080/v1/node/GroveSpeakerD2/sound_ms/600/200?access_token=9164e46e6c460b57b711ac90eca626b9'
            requests.post(url_beep)
        elif leds < 5 :
            url_beep = 'http://192.168.38.58:8080/v1/node/GroveSpeakerD2/sound_ms/400/200?access_token=9164e46e6c460b57b711ac90eca626b9'
            requests.post(url_beep)

        response = requests.get(url_range)
        range_cm = response.json()['range_cm']
        
        time.sleep(.5)
        
    url_leds = 'http://192.168.38.58:8080/v1/node/GroveLedWs2812D0/clear/35/000000?access_token=9164e46e6c460b57b711ac90eca626b9'
    requests.post(url_leds)
    
    print("End")

Video:
[youtube]https://www.youtube.com/watch?v=9w6bnPXLrnQ[/youtube]

This is a great idea and well done. We have one that uses laser guidance for the driver in the garage and it senses the car by heat. On a cold day it does not work so we may try your construction. We think it is one of the best gadgets in the house. Is the range of the ultrasonic sensor too short?

I love it. Good job.

Hi Philip,

I’ve set the range to a such low value just to test the solution in my office.

You can adjust the value in the code:

leds = int(range_cm / 10)