File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ var arduino = require ( '../' )
2+ board , rc ;
3+
4+ var board = new arduino . Board ( {
5+ debug : true
6+ } ) ;
7+
8+ var rc = new arduino . RC ( {
9+ board : board ,
10+ pin : "10"
11+ } ) ;
12+
13+ board . on ( 'ready' , function ( ) {
14+ setTimeout ( function ( ) {
15+ // alternative: rc.decimal("123456")
16+ rc . triState ( "0FFF0FFFFF0F" ) ;
17+ } , 1000 ) ;
18+ setTimeout ( function ( ) {
19+ rc . triState ( "0FFF0FFFFF00" ) ;
20+ } , 2000 ) ;
21+ } ) ;
Original file line number Diff line number Diff line change @@ -8,5 +8,6 @@ module.exports = {
88 Sensor : require ( './lib/sensor' ) ,
99 Ping : require ( './lib/ping' ) ,
1010 PIR : require ( './lib/pir' ) ,
11- LCD : require ( './lib/lcd' )
11+ LCD : require ( './lib/lcd' ) ,
12+ RC : require ( './lib/rc' )
1213} ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Main RC constructor
3+ * Process options
4+ * Tell the board to set it up
5+ */
6+ var RC = function ( options ) {
7+ if ( ! options || ! options . board ) throw new Error ( 'Must supply required options to LED' ) ;
8+ this . board = options . board ;
9+ this . pin = this . board . normalizePin ( options . pin || 10 ) ;
10+ }
11+
12+ /*
13+ * Send triState code
14+ */
15+ RC . prototype . triState = function ( val ) {
16+ var msg = '96' + this . pin + val ;
17+ this . board . write ( msg ) ;
18+ }
19+
20+ /*
21+ * Send decimal code
22+ * val must be 12 chars or less
23+ */
24+ RC . prototype . decimal = function ( val ) {
25+ // at most twelve, null-term if shorter
26+ var terminatedval = ( val + '\0' ) . slice ( 0 , 12 )
27+ var msg = '94' + this . pin + terminatedval ;
28+ this . board . write ( msg ) ;
29+ }
30+
31+ module . exports = RC ;
Original file line number Diff line number Diff line change 66 { "name" : " Seiya Konno" , "email" : " nulltask@gmail.com" },
77 { "name" : " Nathan Vander Wilt" , "email" : " nate@calftrail.com" },
88 { "name" : " Adam Brault (&yet)" , "email" : " contact@andyet.com" },
9- { "name" : " Emanuele Tessore" , "email" : " setola@gmail.com" }
9+ { "name" : " Emanuele Tessore" , "email" : " setola@gmail.com" },
10+ { "name" : " Willi Thiel" , "email" : " ni-c@ni-c.de" },
11+ { "name" : " Tom Janson" , "email" : " priv.tom.janson+duino@gmail.com" }
1012 ],
1113 "name" : " duino" ,
1214 "description" : " Arduino framework for mad scientists" ,
13- "version" : " 0.0.9 " ,
15+ "version" : " 0.0.10 " ,
1416 "keywords" : [
1517 " arduino" ,
1618 " serial" ,
You can’t perform that action at this time.
0 commit comments