-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathsample.py
More file actions
51 lines (37 loc) · 1.13 KB
/
sample.py
File metadata and controls
51 lines (37 loc) · 1.13 KB
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
import time
from bitalino import BITalino
# The macAddress variable on Windows can be "XX:XX:XX:XX:XX:XX" or "COMX"
# while on Mac OS can be "/dev/tty.BITalino-XX-XX-DevB" for devices ending with the last 4 digits of the MAC address or "/dev/tty.BITalino-DevB" for the remaining
macAddress = "00:00:00:00:00:00"
# This example will collect data for 5 sec.
running_time = 5
batteryThreshold = 30
acqChannels = [0, 1, 2, 3, 4, 5]
samplingRate = 1000
nSamples = 10
digitalOutput_on = [1, 1]
digitalOutput_off = [0, 0]
# Connect to BITalino
device = BITalino(macAddress)
# Set battery threshold
device.battery(batteryThreshold)
# Read BITalino version
print(device.version())
# Start Acquisition
device.start(samplingRate, acqChannels)
start = time.time()
end = time.time()
while (end - start) < running_time:
# Read samples
print(device.read(nSamples))
end = time.time()
# Turn BITalino led and buzzer on
device.trigger(digitalOutput_on)
# Script sleeps for n seconds
time.sleep(running_time)
# Turn BITalino led and buzzer off
device.trigger(digitalOutput_off)
# Stop acquisition
device.stop()
# Close connection
device.close()