Hardware Reference
In-Depth Information
Solution
Locate the four onboard LEDs shown in Figure 3-2 . They are labeled USR0 through USR3 ,
but we'll refer to them as the USER LEDs.
Figure 3-2. The four USER LEDs
Place the code shown in Example 3-1 in a file called internLED.js . You can do this using
Cloud9 to edit files (as shown in Recipe 1.6 ) or with a more traditional editor (as shown in
Recipe 5.9 ).
Example 3-1. Using an internal LED (internLED.js)
#!/usr/bin/env node
var b = require ( 'bonescript' );
var LED = 'USR0' ;
var state = b . HIGH ; // Initial state
b . pinMode ( LED , b . OUTPUT );
setInterval ( flash , 250 );
// Change state every 250 ms
function flash () {
b . digitalWrite ( LED , state );
if ( state === b . HIGH ) {
state = b . LOW ;
Search WWH ::




Custom Search