Hardware Reference
In-Depth Information
Example 3-2. Code for using an external LED (externLED.js)
#!/usr/bin/env node
var b = require ( 'bonescript' );
var LED = 'P9_14' ;
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 ;
} else {
state = b . HIGH ;
}
}
Save your file and run the code as before ( Recipe 3.1 ).
Search WWH ::




Custom Search