forked from HashNuke/Python-Arduino-Prototyping-API
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
58 lines (45 loc) · 1.52 KB
/
Copy pathREADME
File metadata and controls
58 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Python Arduino Prototyping API (version: 0.1)
=====================================================
The Python Arduino Prototyping API helps you to quickly prototype Arduino programs,
without having to repeatedly load the program to the Arduino board.
Setup:
1.) Load prototype.pde onto your Arduino dev board.
2.) Import the arduino lib in your python script.
-----------------------------------------------------
METHODS:
-----------------------------------------------------
Arduino.output(list_of_output_pins)
Digital I/O functions:
1.) Arduino.setHigh(pin_number)
2.) Arduino.setLow(pin_number)
3.) Arduino.getState(pin_number)
getState() returns true if pin state is high, else it returns false.
Analog I/O functions:
1.) Arduino.analogRead(pin_number)
returns the analog value
2.) Arduino.analogRead(pin_number, value)
sets the analog value
Misc functions:
1.) Arduino.turnOff()
sets all the pins to low state
2.) Arduino.close()
closes serial connection. Using this makes sure that you won't have
to disconnect & reconnect the Arduino again to recover the serial port.
-----------------------------------------------------
USAGE EXAMPLE:
-----------------------------------------------------
#the blink program
#import the lib
from arduino import Arduino
import time
#specify the port as an argument
my_board = Arduino('/dev/ttyUSB1')
#declare output pins as a list/tuple
my_board.output([11,12,13])
#perform operations
i=0
while(i<10):
my_board.setHigh(13)
time.sleep(1)
my_board.setLow(13)
i+=1