File tree Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change
1
+ #this is used to check the running voltage of arduino.
2
+ try :
3
+ from pyfirmata import Arduino , util
4
+ except :
5
+ import pip
6
+ pip .main (['install' ,'pyfirmata' ])
7
+ from pyfirmata import Arduino , util
8
+
9
+ import time
10
+ board = Arduino ("COM4" )
11
+ it = util .Iterator (board )
12
+ it .start ()
13
+ Tv1 = board .get_pin ('a:0:i' )#'a'nalog/'d'igital:pin number:'i'nput/'o'utput/'p'wm
14
+ time .sleep (1 )
15
+ print (Tv1 .read ())
Original file line number Diff line number Diff line change
1
+ from pyfirmata import Arduino , util
2
+ import time
3
+
4
+ board = Arduino ("COM4" )
5
+ it = util .Iterator (board )
6
+ it .start ()
7
+ print ("Hello!Arduino" )
8
+ LED = board .get_pin ("d:13:o" )
9
+
10
+ while True :
11
+ LED .write (1 )
12
+ time .sleep (0.5 )
13
+ LED .write (0 )
14
+ time .sleep (0.5 )
15
+
16
+ board .exit ()
Original file line number Diff line number Diff line change
1
+ from pyfirmata import Arduino ,util
2
+ import time
3
+
4
+ board = Arduino ("COM4" )
5
+ it = util .Iterator (board )
6
+ it .start ()
7
+
8
+ led = board .get_pin ("d:9:o" )
9
+
10
+ # for a in range(0,255):
11
+ # led.write()
12
+ # time.sleep(0.8)
13
+
14
+ # for a in range(255,0):
15
+ while True :
16
+ a = 0
17
+ while a <= 255 :
18
+ led .write (a )
19
+ time .sleep (0.008 )
20
+ a += 1
21
+ while a >= 0 :
22
+ led .write (a )
23
+ time .sleep (0.008 )
24
+ a -= 1
25
+ time .sleep (0.8 )
26
+ board .exit ()
27
+
28
+
29
+
Original file line number Diff line number Diff line change
1
+ from pyfirmata import Arduino , util
2
+ import time
3
+
4
+ board = Arduino ("COM4" )
5
+ it = util .Iterator (board )
6
+ it .start ()
7
+
8
+ sw = board .get_pin ("d:3:i" )
9
+ led = board .get_pin ("d:13:o" )
10
+
11
+ while True :
12
+ value = sw .read ()
13
+ if value == 1 :
14
+ led .write (1 )
15
+ else :
16
+ led .write (0 )
17
+ board .exit ()
18
+
You can’t perform that action at this time.
0 commit comments