Ejemplo n.º 1
0
 def _perceive(self):
     if not gopigo_available:
         return None
     value = gopigo.analogRead(self.pin)
     if value < 0:
         return None
     return value
Ejemplo n.º 2
0
 def _perceive(self):
     if not gopigo_available:
         return None
     value = gopigo.analogRead(self.pin)
     if value < 0:
         return None
     return value
Ejemplo n.º 3
0
    def read(self):
        _wait_for_read()

        if _is_read_open():
            _grab_read()
            self.value = gopigo.analogRead(self.getPortID())
        _release_read()
        return self.value
Ejemplo n.º 4
0
    def read(self):
        _wait_for_read()

        if _is_read_open():
            _grab_read()
            self.value = gopigo.analogRead(self.getPortID())
        _release_read()
        return self.value
Ejemplo n.º 5
0
 def read(self):
     _grab_read()
     try:
         self.value = gopigo.analogRead(self.getPortID())
     except:
         pass
     _release_read()
     return self.value
Ejemplo n.º 6
0
    def read(self):
        _ifMutexAcquire(self.use_mutex)
        try:
            self.value = gopigo.analogRead(self.getPortID())
        except:
            pass
        finally:
            _ifMutexRelease(self.use_mutex)

        return self.value
Ejemplo n.º 7
0
    def read(self):
        _ifMutexAcquire(self.use_mutex)
        try:
            self.value = gopigo.analogRead(self.getPortID())
        except:
            pass
        finally:
            _ifMutexRelease(self.use_mutex)

        return self.value
Ejemplo n.º 8
0
def temp(pin, model = '1.0'):
	# each of the sensor revisions use different thermistors, each with their own B value constant
	if model == '1.2':
		bValue = 4250  # sensor v1.2 uses thermistor ??? (assuming NCP18WF104F03RC until SeeedStudio clarifies)
	elif model == '1.1':
		bValue = 4250  # sensor v1.1 uses thermistor NCP18WF104F03RC
	else:
		bValue = 3975  # sensor v1.0 uses thermistor TTC3A103*39H
	a = analogRead(pin)
	resistance = (float)(1023 - a) * 10000 / a
	t = (float)(1 / (math.log(resistance / 10000) / bValue + 1 / 298.15) - 273.15)
	return t
Ejemplo n.º 9
0
def temp(pin, model='1.0'):
    # each of the sensor revisions use different thermistors, each with their own B value constant
    if model == '1.2':
        bValue = 4250  # sensor v1.2 uses thermistor ??? (assuming NCP18WF104F03RC until SeeedStudio clarifies)
    elif model == '1.1':
        bValue = 4250  # sensor v1.1 uses thermistor NCP18WF104F03RC
    else:
        bValue = 3975  # sensor v1.0 uses thermistor TTC3A103*39H
    a = analogRead(pin)
    resistance = (float)(1023 - a) * 10000 / a
    t = (float)(1 / (math.log(resistance / 10000) / bValue + 1 / 298.15) -
                273.15)
    return t
Ejemplo n.º 10
0
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import time

import gopigo

# Connect the analog sensor like the sound sensor, light sensor, rotatary sensor to  A1
#   The pin should be 15 for A11 port or you can call the analogPort definitions from the GoPiGo library
#   The analog sensors won't work on any other port

sensor_pin = gopigo.analogPort
gopigo.pinMode(sensor_pin, "INPUT")
while True:
	try:
		print (gopigo.analogRead(sensor_pin))
		time.sleep(.5)

	except IOError:
		print ("Error")
Ejemplo n.º 11
0
#gopigo.fwd()
#time.sleep(2)
#gopigo.bwd()
#time.sleep(2)
gopigo.stop()

sensor_pin = gopigo.analogPort
gopigo.pinMode(sensor_pin,"INPUT")

# calibrate light sensor
print("Calibrating Light Sensor")
base_value = 0
sample_size = 50
light_threshold = 30
for i in range (1, sample_size):
	base_value = base_value + gopigo.analogRead(sensor_pin)

base_light_value = base_value/sample_size

print(base_light_value)
print("Finished calibration")

while True:
	try:
		current_light_value = gopigo.analogRead(sensor_pin)
		print (current_light_value)
		time.sleep(.5)
		if current_light_value > base_light_value + light_threshold:
			print("GOpiGO")
			gopigo.fwd()
			time.sleep(1)
Ejemplo n.º 12
0
 def read(self):
     self.value = gopigo.analogRead(self.getPortID())
     return self.value
Ejemplo n.º 13
0
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import time
import gopigo

# Connect the analog sensor like the sound sensor, light sensor, rotatary sensor to  A1
#   The pin should be 15 for A11 port or you can call the analogPort definitions from the GoPiGo library
#   The analog sensors won't work on any other port

sensor_pin = gopigo.analogPort
gopigo.pinMode(sensor_pin, "INPUT")
while True:
    try:
        print(gopigo.analogRead(sensor_pin))
        time.sleep(.5)

    except IOError:
        print("Error")
Ejemplo n.º 14
0
 def read(self):
     self.value = gopigo.analogRead(self.getPortID())
     return self.value
Ejemplo n.º 15
0
 def read(self):
     I2C_Mutex_Acquire()
     self.value = gopigo.analogRead(self.getPortID())
     I2C_Mutex_Release()
     return self.value
Ejemplo n.º 16
0
def analogRead(kargs):
    r = {'return_value': gopigo.analogRead(int(kargs['pin']))}
    return r