martinohanlon / BlueDot

A zero boiler plate bluetooth remote
MIT License
141 stars 43 forks source link

Add an example with NeoPixel LED strip #164

Open Lalle77 opened 3 years ago

Lalle77 commented 3 years ago

I am quite new to Python programming and eager to learn more about it. Therefore, I have started a hobby project to rebuild a RC car and replace its electronics with a Raspberry PI Zero board and put a WS2812 / NeoPixel Addressable LEDs into it. I found the BlueDot app very suitable for this project and especially the code example for the Robot. I have tried to add an "elif" with additional code to be able to make the LED sling blink when I press the button in middle and stop when I push the button again (toggle function). But, since that part of code consist of a while(1) loop, I run into trouble, because of the endless loop. I have googled for possible solutions and what I have found is a solution with multiprocessing. Would it be possible for you to add code to the robotics code to show an example how multiprocessing works and will be implemented?

The code I want to use to start the LED sling to blink is:

import board import neopixel import time pixels = neopixel.NeoPixel(board.D18, 28)

while True: if n<3: pixels.fill((0,0,255)) time.sleep(0.05) pixels.fill((0,0,0)) time.sleep(0.05) n+=1 else: n=0 time.sleep(0.2)

martinohanlon commented 3 years ago

I would encourage you to take your question to the raspberry pi forum raspberrypi.org/forum, there are lots of friendly people there who would be able to help.

I am the only person who monitors these issues and works on BlueDot and it will take me a while to look into this.