-
Notifications
You must be signed in to change notification settings - Fork 775
/
Copy pathmain.py
59 lines (50 loc) · 1.61 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# SPDX-FileCopyrightText: 2019 Limor Fried for Adafruit Industries
# SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries
#
# SPDX-License-Identifier: MIT
# main.py - code to test the Adafruit CRICKIT board with
# the BBC micro:bit and MicroPython (NOT CircuitPython)
# MIT License by Limor Fried and Anne Barela, 2019
# This code requires the seesaw.py module as a driver
import time
import seesaw
seesaw.init()
while True:
# Touch test - check with the Mu plotter!
print("Touch: \n(", end="")
for i in range(1, 5):
print(seesaw.read_touch(i), end=", \t")
print(")")
# analog read signal test - assumes analog input pin 8
print("Analog signal:\n(", end="")
print(seesaw.analog_read(8), end=", \t")
print(")")
seesaw.write_digital(2, 0) # Assumes LED on Signal pin 2
time.sleep(0.1)
seesaw.write_digital(2, 1)
time.sleep(0.1)
if seesaw.read_digital(7): # Assumes button on Signal pin 7
print("pin high")
else:
print("pin low")
# Servo test - assumes servo on Servo position 1 on CRICKIT
seesaw.servo(1, 0, min=0.5, max=2.5)
time.sleep(0.5)
seesaw.servo(1, 90, min=0.5, max=2.5)
time.sleep(0.5)
seesaw.servo(1, 180, min=0.5, max=2.5)
time.sleep(0.5)
# Drive test
# seesaw.drive(1, 0.2)
# seesaw.drive(2, 0.4)
# seesaw.drive(3, 0.6)
# seesaw.drive(4, 0.8)
# motor test - assumes a DC motor on CRICKIT Motor 1 terminals
seesaw.motor(1, 1)
time.sleep(0.5)
seesaw.motor(1, 0)
time.sleep(0.5)
seesaw.motor(1, -1)
time.sleep(0.5)
seesaw.motor(1, 0)
time.sleep(0.1)