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.
'''

# NOTE: 4x red 7 segment display with colon and 8 luminance levels, but no decimal points

import time
import jetduino
from jetduino_pins import *

# Connect the Grove 4 Digit Display to digital port D5
# CLK,DIO,VCC,GND
display = ARD_D4
jetduino.pinMode(display, OUTPUT_PIN)
jetduino.pinMode(display+1, OUTPUT_PIN)

# If you have an analog sensor connect it to A0 so you can monitor it below
sensor = ARD_A0
jetduino.pinMode(sensor, INPUT_PIN)

time.sleep(.5)

# 4 Digit Display methods
# jetduino.fourDigit_init(pin)
# jetduino.fourDigit_number(pin,value,leading_zero)
# jetduino.fourDigit_brightness(pin,brightness)
# jetduino.fourDigit_digit(pin,segment,value)
# jetduino.fourDigit_segment(pin,segment,leds)
# jetduino.fourDigit_score(pin,left,right)
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 *

sensor = ARD_A0

jetduino.pinMode(sensor, INPUT_PIN)

jetduino.setAnalogReadResolution(10)

while True:
    try:
        sensor_value = jetduino.analogRead(sensor)

        #if sensor_value >= 0:
        print ("sensor_value =", sensor_value)

        time.sleep(.5)

    except IOError:
        print ("Error")
		elif match_sensors(msg,analog_sensors) >=0:
			if en_jetduino:
				s_no=match_sensors(msg,analog_sensors)
				sens=analog_sensors[s_no]
				port=int(msg[len(sens):])
				a_read=jetduino.analogRead(port)
				s.sensorupdate({sens:a_read})
				
			if en_debug:
				print msg
				print sens +'op:'+ str(a_read)
		
		elif msg[:8].lower()=="setInput".lower():
			if en_jetduino:
				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})
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")
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

# 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)
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 *
 
jetduino.pinMode(JET_PU0, INPUT_PIN)
jetduino.pinMode(JET_PU1, INPUT_PIN)
jetduino.pinMode(JET_PU2, INPUT_PIN)
jetduino.pinMode(JET_PU3, INPUT_PIN)
jetduino.pinMode(JET_PU4, INPUT_PIN)
jetduino.pinMode(JET_PU5, INPUT_PIN)
jetduino.pinMode(JET_PU6, INPUT_PIN)

jetduino.pinMode(ARD_D2, INPUT_PIN)
jetduino.pinMode(ARD_D3, INPUT_PIN)
jetduino.pinMode(ARD_D4, INPUT_PIN)
jetduino.pinMode(ARD_D5, INPUT_PIN)
jetduino.pinMode(ARD_D6, INPUT_PIN)
jetduino.pinMode(ARD_D7, INPUT_PIN)
jetduino.pinMode(ARD_D8, INPUT_PIN)
jetduino.pinMode(ARD_D9, INPUT_PIN)
'''

import time
import jetduino
from jetduino_pins import *

# Connect first LED in Chainable RGB LED chain to digital port D7
# In: CI,DI,VCC,GND
# Out: CO,DO,VCC,GND
pin = ARD_D7

# I have 10 LEDs connected in series with the first connected to the jetduino and the last not connected
# First LED input socket connected to jetduino, output socket connected to second LED input and so on
numleds = 10     #If you only plug 1 LED, change 10 to 1

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

# Chainable RGB LED methods
# jetduino.storeColor(red, green, blue)
# jetduino.chainableRgbLed_init(pin, numLeds)
# jetduino.chainableRgbLed_test(pin, numLeds, testColor)
# jetduino.chainableRgbLed_pattern(pin, pattern, whichLed)
# jetduino.chainableRgbLed_modulo(pin, offset, divisor)
# jetduino.chainableRgbLed_setLevel(pin, level, reverse)

# test colors used in jetduino.chainableRgbLed_test()
testColorBlack = 0   # 0b000 #000000
testColorBlue = 1    # 0b001 #0000FF
testColorGreen = 2   # 0b010 #00FF00
testColorCyan = 3    # 0b011 #00FFFF
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 Loudness Sensor to analog port A0
# SIG,NC,VCC,GND
loudness_sensor = ARD_A0

jetduino.pinMode(loudness_sensor, INPUT_PIN)
while True:
    try:
        # Read the sound level
        sensor_value = jetduino.analogRead(loudness_sensor)

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

    except IOError:
        print ("Error")
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

# 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:
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 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:
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 *

# 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:
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 *
 
jetduino.pinMode(JET_PU0, OUTPUT_PIN)
jetduino.pinMode(JET_PU1, OUTPUT_PIN)
jetduino.pinMode(JET_PU2, OUTPUT_PIN)
jetduino.pinMode(JET_PU3, OUTPUT_PIN)
jetduino.pinMode(JET_PU4, OUTPUT_PIN)
jetduino.pinMode(JET_PU5, OUTPUT_PIN)
jetduino.pinMode(JET_PU6, OUTPUT_PIN)

jetduino.pinMode(JET_PK1, OUTPUT_PIN)
jetduino.pinMode(JET_PK2, OUTPUT_PIN)
jetduino.pinMode(JET_PK4, OUTPUT_PIN)

jetduino.pinMode(JET_PH1, OUTPUT_PIN)

jetduino.pinMode(ARD_D2, OUTPUT_PIN)
jetduino.pinMode(ARD_D3, OUTPUT_PIN)
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")
'''
#
# NOTE:
# 	MOSFET is also a kind of switch, but its switching frequency can reach up to 5MHz, much faster than normal mechanical relay.
# 	There are two screw terminals on opposite sides of the board.
# 	One side for power source and the other side for the device you want to control.

import time
import jetduino
from jetduino_pins import *

# Connect the Grove MOSFET to analog port D6
# SIG,NC,VCC,GND
mosfet = ARD_D6

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

while True:
    try:
        # Full speed
        jetduino.analogWrite(mosfet,255)
        print ("full speed")
        time.sleep(2)

        # Half speed
        jetduino.analogWrite(mosfet,128)
        print ("half speed")
        time.sleep(2)

        # Off
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 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")
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 *

# The sensitivity can be adjusted by the onboard potentiometer

# Connect the Grove HCHO Sensor to analog port A0
# SIG,NC,VCC,GND

hcho_sensor = ARD_A0

jetduino.pinMode(hcho_sensor, INPUT_PIN)

# Vcc of the grove interface is normally 5v
grove_vcc = 5

while True:
    try:
        # Get sensor value
        sensor_value = jetduino.analogRead(hcho_sensor)

        # Calculate voltage
        voltage = (float)(sensor_value * grove_vcc / 1024)

        print ("sensor_value =", sensor_value, " voltage =", voltage)
        time.sleep(.5)
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")
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 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)
import time
import jetduino
from jetduino_pins import *
import math

# Connections
sound_sensor = ARD_A0        # port A0
light_sensor = ARD_A1        # port A1 
temperature_sensor = ARD_D4  # port D4
led = ARD_D3                 # port D3

# Connect to Twitter
api = twitter.Api(consumer_key='YourKey',consumer_secret='YourKey',access_token_key='YourKey',access_token_secret='YourKey')
print "Twitter Connected"

jetduino.pinMode(led,"OUTPUT")

last_sound = 0

while True:
    # Error handling in case of problems communicating with the GrovePi
    try:
        # Get value from temperature sensor
        [temp,humidity] = jetduino.dht(temperature_sensor,0)
        t=temp

        # Get value from light sensor
        light_intensity = jetduino.analogRead(light_sensor)

        # Give PWM output to LED
        jetduino.analogWrite(led,light_intensity/4)
# Connect the Grove Thumb Joystick to analog port A0

# GrovePi Port A0 uses Arduino pins 0 and 1
# GrovePi Port A1 uses Arduino pins 1 and 2
# Don't plug anything into port A1 that uses pin 1
# Most Grove sensors only use 3 of their 4 pins, which is why the GrovePi shares Arduino pins between adjacent ports
# If the sensor has a pin definition SIG,NC,VCC,GND, the second (white) pin is not connected to anything

# If you wish to connect two joysticks, use ports A0 and A2 (skip A1)

# Uses two pins - one for the X axis and one for the Y axis
# This configuration means you are using port A0
xPin = ARD_A0
yPin = ARD_A2

jetduino.pinMode(xPin, INPUT_PIN)
jetduino.pinMode(yPin, INPUT_PIN)

# The Grove Thumb Joystick is an analog device that outputs analog signal ranging from 0 to 1023
# The X and Y axes are two ~10k potentiometers and a momentary push button which shorts the x axis

# My joystick produces slightly different results to the specifications found on the url above
# I've listed both here:

# Specifications
#     Min  Typ  Max  Click
#  X  206  516  798  1023
#  Y  203  507  797

# My Joystick
#     Min  Typ  Max  Click
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")
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")
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")
THE SOFTWARE.
'''

import time
import jetduino
from jetduino_pins import *

# Connect the Grove Slide Potentiometer to analog port A0
# OUT,LED,VCC,GND
slide = ARD_A0

# The device has an onboard LED accessible as pin 2 on port A0
# OUT,LED,VCC,GND
led = ARD_D1     # pin 2 (white wire)

jetduino.pinMode(slide, INPUT_PIN)
jetduino.pinMode(led, OUTPUT_PIN)
time.sleep(1)

while True:
    try:
        # Read sensor value from potentiometer
        sensor_value = jetduino.analogRead(slide)

        # Illuminate onboard LED
        if sensor_value > 500:
            jetduino.digitalWrite(led, HIGH)
        else:
            jetduino.digitalWrite(led, LOW)

        print ("sensor_value =", sensor_value)
import time
import jetduino
from jetduino_pins import *

# Connect the Grove LED to digital port D4
# SIG,NC,VCC,GND
led = ARD_D4

# Digital ports that support Pulse Width Modulation (PWM)
# D2-D13, DAC1, DAC2

# Digital ports that do not support PWM
# D14-D54

jetduino.pinMode(led, OUTPUT_PIN)
time.sleep(0.1)
i = 0


while True:
    try:
        # Reset
        if i > 255:
            i = 0

        # Current brightness
        print (i)

        # Give PWM output to LED
        jetduino.analogWrite(led,i)
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 *
 
jetduino.pinMode(ARD_A0, INPUT_PIN)
jetduino.pinMode(ARD_A1, INPUT_PIN)
jetduino.pinMode(ARD_A2, INPUT_PIN)
jetduino.pinMode(ARD_A3, INPUT_PIN)
jetduino.pinMode(ARD_A4, INPUT_PIN)
jetduino.pinMode(ARD_A5, INPUT_PIN)
jetduino.pinMode(ARD_A6, INPUT_PIN)
jetduino.pinMode(ARD_A7, INPUT_PIN)
jetduino.pinMode(ARD_A8, INPUT_PIN)
jetduino.pinMode(ARD_A9, INPUT_PIN)
jetduino.pinMode(ARD_A10, INPUT_PIN)
jetduino.pinMode(ARD_A11, INPUT_PIN)

jetduino.setAnalogReadResolution(10)

def readDigital():
'''

# NOTE:
# 	Relay is both normally open and normally closed.
# 	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)
'''


import time
import jetduino
from jetduino_pins import *

# Connect the Grove Rotary Angle Sensor to analog port A0
# SIG,NC,VCC,GND
potentiometer = ARD_A0

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

jetduino.pinMode(potentiometer, INPUT_PIN)
jetduino.pinMode(led, OUTPUT_PIN)
time.sleep(1)

# Reference voltage of ADC is 5v
adc_ref = 5

# Vcc of the grove interface is normally 5v
grove_vcc = 5

# Full value of the rotary angle is 300 degrees, as per it's specs (0 to 300)
full_angle = 300

while True:
    try:
        # Read sensor value from potentiometer