arduino:vl53l0x
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| arduino:vl53l0x [2019/03/02 19:01] – aistis | arduino:vl53l0x [2025/06/02 22:29] (current) – aistis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | {{: | ||
| + | |||
| VL53L0X 940nm | VL53L0X 940nm | ||
| GY-53 VL53L0X console version | GY-53 VL53L0X console version | ||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | <code python> | ||
| + | |||
| + | import matplotlib.pyplot as plt | ||
| + | import numpy as np | ||
| + | import serial | ||
| + | import time | ||
| + | from matplotlib import pyplot as plt | ||
| + | |||
| + | s = serial.Serial(port=' | ||
| + | time.sleep(0.1) | ||
| + | while s.in_waiting == 0: time.sleep(0.01) #wait for first byte to arrive | ||
| + | while s.in_waiting != 0: #skip bytes until pause | ||
| + | s.read(1) | ||
| + | time.sleep(0.01) | ||
| + | |||
| + | x = np.arange(100) | ||
| + | y = np.zeros(100) | ||
| + | |||
| + | plt.ion() | ||
| + | fig = plt.figure(1) | ||
| + | plt.ylim(ymax=250, | ||
| + | ax = fig.add_subplot(111) | ||
| + | line1, = ax.plot(x, y, ' | ||
| + | i = 0 | ||
| + | while True: | ||
| + | if not plt.fignum_exists(1): | ||
| + | buf = s.read(9) | ||
| + | print(" | ||
| + | ii = i | ||
| + | if ii >= 100: | ||
| + | y = np.roll(y, -1) | ||
| + | ii = 99 | ||
| + | y[ii] = buf[5] | ||
| + | line1.set_ydata(y) | ||
| + | fig.canvas.draw() | ||
| + | fig.canvas.flush_events() | ||
| + | i = i + 1 | ||
| + | </ | ||
arduino/vl53l0x.1551546116.txt.gz · Last modified: by aistis
