File tree Expand file tree Collapse file tree 7 files changed +51
-6
lines changed Expand file tree Collapse file tree 7 files changed +51
-6
lines changed Original file line number Diff line number Diff line change 55
55
"name" : " PHPiWire" ,
56
56
"description" : " Control the RaspberryPi GPIO via PHP (with wiringPi)" ,
57
57
"author" : " Andrew Collington (andy@amnuts.com)" ,
58
- "version" : " 0.0.1 " ,
58
+ "version" : " 0.1.0 " ,
59
59
"verbose" : false ,
60
60
"requires" : {
61
61
"extensions" : []
Original file line number Diff line number Diff line change 6
6
* Example of blinking an LED connected to pin 0
7
7
*
8
8
* @author Andrew Collington, andy@amnuts.com
9
- * @version 0.0.1
9
+ * @version 0.1.0
10
10
* @link https://github.com/amnuts/phpiwire
11
11
* @license MIT, http://acollington.mit-license.org/
12
12
*/
Original file line number Diff line number Diff line change 6
6
* Get the board information
7
7
*
8
8
* @author Andrew Collington, andy@amnuts.com
9
- * @version 0.0.1
9
+ * @version 0.1.0
10
10
* @link https://github.com/amnuts/phpiwire
11
11
* @license MIT, http://acollington.mit-license.org/
12
12
*/
Original file line number Diff line number Diff line change 6
6
* Checking pin status
7
7
*
8
8
* @author Andrew Collington, andy@amnuts.com
9
- * @version 0.0.1
9
+ * @version 0.1.0
10
10
* @link https://github.com/amnuts/phpiwire
11
11
* @license MIT, http://acollington.mit-license.org/
12
12
*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Phpiwire: A PHP wrapper for wiringPi
5
+ *
6
+ * Example of using hardware PWM to pulse an LED.
7
+ *
8
+ * @author Andrew Collington, andy@amnuts.com
9
+ * @version 0.1.0
10
+ * @link https://github.com/amnuts/phpiwire
11
+ * @license MIT, http://acollington.mit-license.org/
12
+ */
13
+
14
+ namespace Phpiwire ;
15
+
16
+ if (PHP_SAPI !== 'cli ' ) {
17
+ echo 'Sorry, you can only use this via the command line. ' ;
18
+ return ;
19
+ }
20
+
21
+ set_time_limit (0 );
22
+
23
+ echo "Raspberry Pi pulse - use ^C to stop \n" ;
24
+
25
+ $ pi = new Board ();
26
+ $ p = $ pi ->getPin (1 )->mode (Pin::PWM_OUT );
27
+ $ p ->pwmWrite (0 );
28
+
29
+ $ sleep = 500 ;
30
+ $ pwmValue = 1024 ; // 0 min, 1024 max
31
+
32
+ while (true ) {
33
+ for ($ i = 0 ; $ i <= $ pwmValue ; ++$ i ) {
34
+ $ p ->pwmWrite ($ i );
35
+ usleep ($ sleep );
36
+ }
37
+ sleep (1 );
38
+ for ($ i = $ pwmValue ; $ i > 0 ; --$ i ) {
39
+ $ p ->pwmWrite ($ i );
40
+ usleep ($ sleep );
41
+ }
42
+ }
Original file line number Diff line number Diff line change 2
2
* Phpiwire: A PHP wrapper for wiringPi
3
3
*
4
4
* @author Andrew Collington, andy@amnuts.com
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
* @link https://github.com/amnuts/phpiwire
7
7
* @license MIT, http://acollington.mit-license.org/
8
8
*
Original file line number Diff line number Diff line change 2
2
* Phpiwire: A PHP wrapper for wiringPi
3
3
*
4
4
* @author Andrew Collington, andy@amnuts.com
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
* @link https://github.com/amnuts/phpiwire
7
7
* @license MIT, http://acollington.mit-license.org/
8
8
*
@@ -204,6 +204,9 @@ class Pin
204
204
case self :: ANALOG :
205
205
% { analogWrite(pin, value); }%
206
206
break ;
207
+ case self :: PWM :
208
+ % { pwmWrite(pin, value); }%
209
+ break ;
207
210
}
208
211
209
212
return this ;
You can’t perform that action at this time.
0 commit comments