Simple test
Ensure your device works with this simple test.
examples/dymoscale_simpletest.py
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5
6import board
7import digitalio
8
9import adafruit_dymoscale
10
11# initialize the dymo scale
12units_pin = digitalio.DigitalInOut(board.D3)
13units_pin.switch_to_output()
14dymo = adafruit_dymoscale.DYMOScale(board.D4, units_pin)
15
16# take a reading of the current time
17time_stamp = time.monotonic()
18
19while True:
20 reading = dymo.weight
21 text = f"{reading.weight} g"
22 print(text)
23 # to avoid sleep mode, toggle the units pin every 2 mins.
24 if (time.monotonic() - time_stamp) > 120:
25 print("toggling units button...")
26 dymo.toggle_unit_button()
27 # reset the time
28 time_stamp = time.monotonic()