Esempio n. 1
0
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 jetduino
from jetduino_pins import *

# SIG,NC,VCC,GND
button = ARD_D2
led = ARD_D4

jetduino.pinMode(button, INPUT_PIN)
jetduino.pinMode(led, OUTPUT_PIN)

while True:
    try:
        val = jetduino.digitalRead(button)
        print ("LED %d" % val)
        jetduino.digitalWrite(led, val)
        time.sleep(1)

    except IOError:
        print ("Error")
				port=int(msg[8:])
				jetduino.pinMode(port,"INPUT")
			if en_debug:
				print msg	
				
		elif msg[:9].lower()=="setOutput".lower():
			if en_jetduino:
				port=int(msg[9:])
				jetduino.pinMode(port,"OUTPUT")
			if en_debug:
				print msg
				
		elif msg[:11].lower()=="digitalRead".lower():
			if en_jetduino:
				port=int(msg[11:])
				d_read=jetduino.digitalRead(port)
				s.sensorupdate({'digitalRead':d_read})
			if en_debug:
				print msg
				print "Digital Reading: " + str(d_read)
		
		elif match_sensors(msg,digitalInp) >=0:
			if en_jetduino:
				s_no=match_sensors(msg,digitalInp)
				sens=digitalInp[s_no]
				port=int(msg[len(sens):])
				sens += str(port)
				jetduino.pinMode(port,"INPUT")
				d_read=jetduino.digitalRead(port)
				s.sensorupdate({sens:d_read})
			if en_debug:
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 jetduino
from jetduino_pins import *

# Connect the Grove Touch Sensor to digital port D4
# SIG,NC,VCC,GND
touch_sensor = ARD_D4

jetduino.pinMode(touch_sensor, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(touch_sensor))
        time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Flame Sensor to digital port D2
# SIG,NC,VCC,GND
flame_sensor = ARD_D2

jetduino.pinMode(flame_sensor, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(flame_sensor))
        time.sleep(.5)

    except IOError:
        print ("Error")
def readDigital():
    pu0 = jetduino.digitalRead(JET_PU0)
    pu1 = jetduino.digitalRead(JET_PU1)
    pu2 = jetduino.digitalRead(JET_PU2)
    pu3 = jetduino.digitalRead(JET_PU3)
    pu4 = jetduino.digitalRead(JET_PU4)
    pu5 = jetduino.digitalRead(JET_PU5)
    pu6 = jetduino.digitalRead(JET_PU6)

    ar2 = jetduino.digitalRead(ARD_D2)
    ar3 = jetduino.digitalRead(ARD_D3)
    ar4 = jetduino.digitalRead(ARD_D4)
    ar5 = jetduino.digitalRead(ARD_D5)
    ar6 = jetduino.digitalRead(ARD_D6)
    ar7 = jetduino.digitalRead(ARD_D7)
    ar8 = jetduino.digitalRead(ARD_D8)
    ar9 = jetduino.digitalRead(ARD_D9)
    ar10 = jetduino.digitalRead(ARD_D10)
    ar11 = jetduino.digitalRead(ARD_D11)
    ar12 = jetduino.digitalRead(ARD_D12)
    ar13 = jetduino.digitalRead(ARD_D13)

    print("JET: %d, %d, %d, %d, %d, %d, %d ARD: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d" % (pu0, pu1, pu2, pu3, pu4, pu5, pu6, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12, ar13)) 
    print("")
Esempio n. 6
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 jetduino
from jetduino_pins import *

# Connect the Grove Switch to digital port D3
# SIG,NC,VCC,GND
switch = ARD_D3

jetduino.pinMode(switch, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(switch))
        time.sleep(.5)

    except IOError:
        print ("Error")
# The sensitivity can be adjusted by the onboard potentiometer
# Calibration
# 	Hold the sensor facing an empty dark area
# 	Adjust the potentiometer until the onboard LED switches off
# 	When the LED switches off the sensor is calibrated
# 	If not, adjust the potentiometer again

import time
import jetduino
from jetduino_pins import *

# Connect the Grove Infrared Distance Interrupt Sensor to digital port D4
# SIG,NC,VCC,GND
sensor = ARD_D4

jetduino.pinMode(sensor, INPUT_PIN)

while True:
    try:
        # Sensor returns LOW and onboard LED lights up when the
        # received infrared light intensity exceeds the calibrated level
        if jetduino.digitalRead(sensor) == 0:
            print ("found something")
        else:
            print ("nothing")

        time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Tilt Switch to digital port D3
# SIG,NC,VCC,GND
tilt_switch = ARD_D3

jetduino.pinMode(tilt_switch, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(tilt_switch))
        time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Water Sensor to digital port D2
# SIG,NC,VCC,GND
water_sensor = ARD_D2

jetduino.pinMode(water_sensor, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(water_sensor))
        time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Magnetic Switch to digital port D3
# SIG,NC,VCC,GND
magnetic_switch = ARD_D3

jetduino.pinMode(magnetic_switch, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(magnetic_switch))
        time.sleep(.5)

    except IOError:
        print ("Error")
	
# 	retriggerable means the sensor will continue outputting high if motion was detected before the hold timer expires.
# 	non-retriggerable means the sensor will output high for the specified hold time only, then output low until motion is detected again.
# 	if there is constant motion detected, retriggerable will stay high for the duration and non-retriggerable will oscillate between high/low.

import time
import jetduino
from jetduino_pins import *

# Connect the Grove PIR Motion Sensor to digital port D8
# SIG,NC,VCC,GND
pir_sensor = ARD_D7 
motion=0
jetduino.pinMode(pir_sensor, INPUT_PIN)

while True:
	try:
		# Sense motion, usually human, within the target range
		motion=jetduino.digitalRead(pir_sensor)
		if motion==0 or motion==1:	# check if reads were 0 or 1 it can be 255 also because of IO Errors so remove those values
			if motion==1:
				print ('Motion Detected')
			else:
				print ('-')

			# if your hold time is less than this, you might not see as many detections
		time.sleep(.2)

	except IOError:
		print ("Error")
import time
import jetduino
from jetduino_pins import *

# Connect the Grove Switch to digital port D3
# SIG,NC,VCC,GND
switch = ARD_D3

# Connect the Grove Relay to digital port D4
# SIG,NC,VCC,GND
relay = ARD_D4

jetduino.pinMode(switch, INPUT_PIN)
jetduino.pinMode(relay, OUTPUT_PIN)

while True:
    try:
        if jetduino.digitalRead(switch):
            jetduino.digitalWrite(relay, HIGH)
        else:
            jetduino.digitalWrite(relay, LOW)

        time.sleep(.5)

    except KeyboardInterrupt:
        jetduino.digitalWrite(relay, LOW)
        break
    except IOError:
        print ("Error")
'''
import time
import jetduino
from jetduino_pins import *

# Connect the Grove Button to digital Port 4.
button = ARD_D4		# This is the D4 pin.
buzzer = ARD_D8		# This is the D8 pin.

jetduino.pinMode(button, INPUT_PIN)
jetduino.pinMode(buzzer, OUTPUT_PIN)

print "GrovePi Basic Hardware Test."
print "Setup:  Connect the button sensor to port D4.  Connect a Grove LED to port D8."
print "Press the button and the buzzer will buzz!"

while True:
    try:
		butt_val = jetduino.digitalRead(button)	# Each time we go through the loop, we read D4.
		print (butt_val)						# Print the value of D4.
		if butt_val > 0:
			jetduino.digitalWrite(buzzer, HIGH)
			print ('start')
			time.sleep(1)
		else:
			jetduino.digitalWrite(buzzer, LOW)
			time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Collision Sensor to digital port D2
# SIG,NC,VCC,GND
collision_sensor = ARD_D2

jetduino.pinMode(collision_sensor, INPUT_PIN)

while True:
    try:
        print (jetduino.digitalRead(collision_sensor))
        time.sleep(.5)

    except IOError:
        print ("Error")
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 jetduino
from jetduino_pins import *

# Connect the Grove Line Finder to digital port D7
# SIG,NC,VCC,GND
line_finder = ARD_D7

jetduino.pinMode(line_finder, INPUT_PIN)

while True:
    try:
        # Return HIGH when black line is detected, and LOW when white line is detected
        if jetduino.digitalRead(line_finder) == HIGH:
            print ("black line detected")
        else:
            print ("white line detected")

        time.sleep(.5)

    except IOError:
        print ("Error")