forked from DexterInd/GoPiGo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_example.py
More file actions
executable file
·51 lines (46 loc) · 1.7 KB
/
basic_example.py
File metadata and controls
executable file
·51 lines (46 loc) · 1.7 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
#!/usr/bin/env python
# Dexter Industries line sensor basic example
#
# This example shows a basic example to read sensor data from the line sensor. Most basic example prints out the data from the 5 sensors on the line follower.
#
# Have a question about this example? Ask on the forums here: http://www.dexterindustries.com/forum/?forum=gopigo
#
#
# Initial Date: 13 Dec 2015 Karan Nayan
# Last Updated: 16 Feb 2016 John Cole
# http://www.dexterindustries.com/
'''
## License
Copyright (C) 2017 Dexter Industries
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
'''
from __future__ import print_function
from __future__ import division
from builtins import input
# the above lines are meant for Python3 compatibility.
# they force the use of Python3 functionality for print(),
# the integer division and input()
# mind your parentheses!
import line_sensor
import time
def get_sensorval():
while True:
val=line_sensor.read_sensor()
if val[0]!=-1:
return val
#else:
#Read once more to clear buffer and remove junk values
# val=line_sensor.read_sensor()
while True:
l0,l1,l2,l3,l4=get_sensorval()
print (l0,l1,l2,l3,l4)
#time.sleep(.05)