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