Exemplo n.º 1
0
# 	When the coil is energised, they will both flip.
# 	LED will illuminate when normally open is closed (and normally closed is open).

import time
import jetduino
from jetduino_pins import *v

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

jetduino.pinMode(relay, OUTPUT_PIN)

while True:
    try:
        # switch on for 5 seconds
        jetduino.digitalWrite(relay, HIGH)
        print ("on")
        time.sleep(5)

        # switch off for 5 seconds
        jetduino.digitalWrite(relay, LOW)
        print ("off")
        time.sleep(5)

    except KeyboardInterrupt:
        jetduino.digitalWrite(relay, LOW)
        break
    except IOError:
        print ("Error")
Exemplo n.º 2
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")
Exemplo n.º 3
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:
				print msg,
				print sens +' output:'+ str(d_read)
				
		elif msg[:16].lower()=="digitalWriteHigh".lower():
			if en_jetduino:
				port=int(msg[16:])
				jetduino.digitalWrite(port,1)
			if en_debug:
				print msg
				
		elif msg[:15].lower()=="digitalWriteLow".lower():
			if en_jetduino:
				port=int(msg[15:])
				jetduino.digitalWrite(port,0)
			if en_debug:
				print msg

		elif match_sensors(msg,pwm) >=0:
			if en_jetduino:
				s_no=match_sensors(msg,pwm)
				sens=pwm[s_no]
				l=len(sens)
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 PU0
# Connect the Grove LED to PU2
# SIG,NC,VCC,GND
button = JET_PU1
led = JET_PU2

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

while True:
    try:
        button_val = jetduino.digitalRead(button)
        print ("Button value is %d" % button_val)
        jetduino.digitalWrite(led, button_val)
        time.sleep(.5)

    except IOError:
        print ("Error")
Exemplo n.º 5
0
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import time
import jetduino

# Connect the Grove Buzzer to digital port D8
# SIG,NC,VCC,GND
buzzer = ARD_D8

jetduino.pinMode(buzzer, OUTPUT_PIN)

while True:
    try:
        # Buzz for 1 second
        jetduino.digitalWrite(buzzer, HIGH)
        print ('start')
        time.sleep(1)

        # Stop buzzing for 1 second and repeat
        jetduino.digitalWrite(buzzer, LOW)
        print ('stop')
        time.sleep(1)

    except KeyboardInterrupt:
        jetduino.digitalWrite(buzzer, LOW)
        break
    except IOError:
        print ("Error")
# Connect the Grove Sound Sensor to analog port A0
# SIG,NC,VCC,GND
sound_sensor = ARD_A0

# Connect the Grove LED to digital port D5
# SIG,NC,VCC,GND
led = LED_D4

jetduino.pinMode(led, OUTPUT_PIN)

# The threshold to turn the led on 400.00 * 5 / 1024 = 1.95v
threshold_value = 600

while True:
    try:
        # Read the sound level
        sensor_value = jetduino.analogRead(sound_sensor)

        # If loud, illuminate LED, otherwise dim
        if sensor_value > threshold_value:
            jetduino.digitalWrite(led, HIGH)
        else:
            jetduino.digitalWrite(led, LOW)

        print ("sensor_value =", sensor_value)
        time.sleep(.5)

    except IOError:
        print ("Error")
def writeDigital(val):
    jetduino.digitalWrite(pin, val)
THE SOFTWARE.
'''

import time
import jetduino
from jetduino_pins import *

# Connect the Grove Vibration Motor to digital port D8
# SIG,NC,VCC,GND
vibration_motor = ARD_D8

jetduino.pinMode(vibration_motor, OUTPUT_PIN)

while True:
    try:
        # Start vibrating for 1 second
        jetduino.digitalWrite(vibration_motor, HIGH)
        print ('start')
        time.sleep(1)

        # Stop vibrating for 1 second, then repeat
        jetduino.digitalWrite(vibration_motor, LOW)
        print ('stop')
        time.sleep(1)

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

# The electromagnet can hold a 1KG weight

# Connect the Grove Electromagnet to digital port D4
# SIG,NC,VCC,GND
electromagnet = ARD_D4

jetduino.pinMode(electromagnet, OUTPUT_PIN)
time.sleep(1)

while True:
    try:
        # Switch on electromagnet
        jetduino.digitalWrite(electromagnet, HIGH)
        print ("on")
        time.sleep(2)

        # Switch off electromagnet
        jetduino.digitalWrite(electromagnet, LOW)
        print ("off")
        time.sleep(2)

    except KeyboardInterrupt:
        jetduino.digitalWrite(electromagnet, LOW)
        break
    except IOError:
        print ("Error")
Exemplo n.º 10
0
def writeDigital(val):
    jetduino.digitalWrite(JET_PU0, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU1, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU2, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU3, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU4, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU5, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PU6, val)
    time.sleep(0.05)

    jetduino.digitalWrite(JET_PK1, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PK2, val)
    time.sleep(0.05)
    jetduino.digitalWrite(JET_PK4, val)
    time.sleep(0.05)

    jetduino.digitalWrite(JET_PH1, val)
    time.sleep(0.05)

    jetduino.digitalWrite(ARD_D2, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D3, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D4, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D5, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D6, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D7, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D8, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D9, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D10, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D11, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D12, val)
    time.sleep(0.05)
    jetduino.digitalWrite(ARD_D13, val)
    time.sleep(0.05)