Skip to content

Instantly share code, notes, and snippets.

@benevpi benevpi/
Created Nov 1, 2019

What would you like to do?
import board
import neopixel
from adafruit_ble.uart_server import UARTServer
from time import sleep
import adafruit_thermistor
import analogio
import math
from adafruit_bluefruit_connect.packet import Packet
from adafruit_bluefruit_connect.location_packet import LocationPacket
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10)
uart_server = UARTServer()
current_long = 0
current_lat = 0
while True:
# Advertise when not connected.
while not uart_server.connected:
while uart_server.connected:
packet = Packet.from_stream(uart_server)
if isinstance(packet, LocationPacket):
#print(packet.longitude, packet.latitude)
delta_long = current_long - packet.longitude
delta_lat = current_lat - packet.latitude
distance = math.sqrt((delta_long * delta_long) + (delta_lat * delta_lat))
current_long = packet.longitude
current_lat = packet.latitude
speed = distance * 100000
for i in range(0,min(speed,9)):
pixels[i] = (100,0,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.