22from Arduino import Arduino
33import time
44
5- def Blink (led_pin ,baud ):
5+ def Blink (led_pin ,baud , port = "" ):
66"""
77 Blinks an LED in 1 sec intervals
88 """
9- board = Arduino (baud )
9+ board = Arduino (baud , port = port )
1010while True :
1111board .digitalWrite (led_pin ,"LOW" )
1212print board .digitalRead (led_pin ) #confirm LOW (0)
@@ -15,12 +15,12 @@ def Blink(led_pin,baud):
1515print board .digitalRead (led_pin ) #confirm HIGH (1)
1616time .sleep (1 )
1717
18- def softBlink (led_pin ,baud ):
18+ def softBlink (led_pin ,baud , port = "" ):
1919"""
2020 Fades an LED off and on, using
2121 Arduino's analogWrite (PWM) function
2222 """
23- board = Arduino (baud )
23+ board = Arduino (baud , port = port )
2424i = 0
2525while True :
2626i += 1
@@ -30,25 +30,25 @@ def softBlink(led_pin,baud):
3030k = 510 - k
3131board .analogWrite (led_pin ,k )
3232
33- def adjustBrightness (pot_pin ,led_pin ,baud ):
33+ def adjustBrightness (pot_pin ,led_pin ,baud , port = "" ):
3434"""
3535 Adjusts brightness of an LED using a
3636 potentiometer
3737 """
38- board = Arduino (baud )
38+ board = Arduino (baud , port = port )
3939while True :
4040time .sleep (0.01 )
4141val = board .analogRead (pot_pin )/ 4
4242print val
4343board .analogWrite (led_pin ,val )
4444
4545
46- def PingSonar (pw_pin ,baud ):
46+ def PingSonar (pw_pin ,baud , port = "" ):
4747"""
4848 Gets distance measurement from Ping)))
4949 ultrasonic rangefinder connected to pw_pin
5050 """
51- board = Arduino (baud )
51+ board = Arduino (baud , port = port )
5252pingPin = pw_pin
5353while True :
5454duration = board .pulseIn (pingPin , "HIGH" )
@@ -57,12 +57,12 @@ def PingSonar(pw_pin,baud):
5757print inches ,"inches"
5858time .sleep (0.1 )
5959
60- def LCD (tx ,baud ,ssbaud ,message ):
60+ def LCD (tx ,baud ,ssbaud ,message , port = "" ):
6161"""
6262 Prints to two-line LCD connected to
6363 pin tx
6464 """
65- board = Arduino (baud )
65+ board = Arduino (baud , port = port )
6666board .SoftwareSerial .begin (0 ,tx ,ssbaud )
6767while True :
6868board .SoftwareSerial .write (" test " )
0 commit comments