mirror of
https://github.com/thearn/Python-Arduino-Command-API.git
synced 2026-01-10 23:18:08 -05:00
fixed test
This commit is contained in:
14
examples.py
14
examples.py
@@ -7,6 +7,7 @@ def Blink(led_pin,baud, port = ""):
|
||||
Blinks an LED in 1 sec intervals
|
||||
"""
|
||||
board = Arduino(baud, port=port)
|
||||
board.pinMode(13, "INPUT")
|
||||
while True:
|
||||
board.digitalWrite(led_pin,"LOW")
|
||||
print board.digitalRead(led_pin) #confirm LOW (0)
|
||||
@@ -67,16 +68,5 @@ def LCD(tx,baud,ssbaud,message, port=""):
|
||||
while True:
|
||||
board.SoftwareSerial.write(" test ")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
a = Arduino('9600', port="/dev/tty.usbserial-A700e08i")
|
||||
print a.Servos.attach(2),"attach"
|
||||
import time
|
||||
i = 0
|
||||
while True:
|
||||
a.Servos.write(2,10*i)
|
||||
time.sleep(.1)
|
||||
print a.Servos.read(2),10*i
|
||||
i+=1
|
||||
Blink(13, '9600', port="/dev/tty.usbserial-A700e08i")
|
||||
@@ -13,7 +13,7 @@ should at least be maintained here.
|
||||
|
||||
|
||||
class TestBasics(unittest.TestCase):
|
||||
_ = raw_input('Plug in Arduino board w/LED at pin 13, then press enter')
|
||||
_ = raw_input('Plug in Arduino board w/LED at pin 13, reset, then press enter')
|
||||
board = Arduino('9600')
|
||||
|
||||
def test_find(self):
|
||||
@@ -22,22 +22,5 @@ class TestBasics(unittest.TestCase):
|
||||
"""
|
||||
self.assertIsNotNone(self.board.port)
|
||||
|
||||
def test_blink(self):
|
||||
"""
|
||||
Tests digital pin functionality
|
||||
"""
|
||||
led_pin = 13
|
||||
self.board.digitalWrite(led_pin, "LOW")
|
||||
state = self.board.digitalRead(led_pin)
|
||||
self.assertEqual(state, 0)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
self.board.digitalWrite(led_pin, "HIGH")
|
||||
state = self.board.digitalRead(led_pin)
|
||||
self.assertEqual(state, 1)
|
||||
|
||||
self.board.digitalWrite(led_pin, "LOW")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user