示例#1
0
    line1.set_ydata(nrn_left.history(10000))  # update line data
    line2.set_ydata(nrn_center.history(10000))
    line3.set_ydata(nrn_right.history(10000))
    ax.draw_artist(line1)  # redraw line
    ax.draw_artist(line2)
    ax.draw_artist(line3)
    plt.pause(0.001)  # push the update
    ## /Comment to remove plotting

    ## Comment to remove driving
    if right_spikes > left_spikes and right_spikes > center_spikes:
        drv.right()

    elif left_spikes > right_spikes and left_spikes > center_spikes:
        drv.left()

    elif center_spikes > left_spikes and center_spikes > right_spikes:
        drv.forward()
    ## /Comment to remove driving

    else:
        drv.stop()

    if keyboard.is_pressed('q'):
        time.sleep(0.2)
        drv.stop()
        time.sleep(0.2)
        drv.close()
        plr.close()
        break