def __init__(self, port, pinmode): ''' port = one of PORTS keys pinmode = "INPUT", "OUTPUT", "SERIAL" (which gets ignored) ''' debug("Sensor init") debug(pinmode) self.setPort(port) self.setPinMode(pinmode) if pinmode == "INPUT" or pinmode == "OUTPUT": gopigo.pinMode(self.getPortID(), self.getPinMode())
def __init__(self, port, pinmode, use_mutex=False): ''' port = one of PORTS keys pinmode = "INPUT", "OUTPUT", "SERIAL" (which gets ignored), "SERVO" ''' debug("Sensor init") debug(pinmode) self.setPort(port) self.setPinMode(pinmode) self.use_mutex = use_mutex if pinmode == "INPUT" or pinmode == "OUTPUT": try: gopigo.pinMode(self.getPortID(), self.getPinMode()) except: pass
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")
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 Grove LED to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The LED won't work on any other port led_pin = gopigo.analogPort # led_pin = gopigo.digitalPort gopigo.pinMode(led_pin, "OUTPUT") while True: try: print "1" gopigo.digitalWrite(led_pin, 1) time.sleep(.5) print "0" gopigo.digitalWrite(led_pin, 0) time.sleep(.5) except IOError: print ("Error")
def _open(self): if not gopigo_available: return False gopigo.pinMode(self.pin, 'INPUT') return True
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")
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 Grove Button to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The button won't work on any other port # button_pin = gopigo.analogPort button_pin = 11 gopigo.pinMode(button_pin,"INPUT") while True: try: print (gopigo.digitalRead(button_pin)) time.sleep(.5) except IOError: print ("Error")
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 Grove LED to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The LED won't work on any other port led_pin = gopigo.analogPort # led_pin = gopigo.digitalPort gopigo.pinMode(led_pin, "OUTPUT") while True: try: print "1" gopigo.digitalWrite(led_pin, 1) time.sleep(.5) print "0" gopigo.digitalWrite(led_pin, 0) time.sleep(.5) except IOError: print("Error")
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 Grove Button to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The button won't work on any other port # button_pin = gopigo.analogPort button_pin = 11 gopigo.pinMode(button_pin, "INPUT") while True: try: print(gopigo.digitalRead(button_pin)) time.sleep(.5) except IOError: print("Error")
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 Grove PIR motion sensor to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The sensor won't work on any other port # motion_sensor_pin = gopigo.digitalPort motion_sensor_pin = gopigo.analogPort gopigo.pinMode(motion_sensor_pin,"INPUT") while True: try: print (gopigo.digitalRead(motion_sensor_pin)) time.sleep(.5) except IOError: print ("Error")
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 Grove PIR motion sensor to digital port D10 or A1 # The pin should be 15 for A11 port and 10 for the D10 digital port or you can call the analogPort or digitalPort definitions from the GoPiGo library # The sensor won't work on any other port # motion_sensor_pin = gopigo.digitalPort motion_sensor_pin = gopigo.analogPort gopigo.pinMode(motion_sensor_pin, "INPUT") while True: try: print(gopigo.digitalRead(motion_sensor_pin)) time.sleep(.5) except IOError: print("Error")
def pinMode(kargs): r = {'return_value': gopigo.pinMode(int(kargs['pin']), int(kargs['mode']))} return r