Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/node
- const fs = require('fs');
- const LED0 = "/sys/class/leds/beaglebone:green:usr0";
- // initialize LED0
- fs.writeFileSync(LED0+'/trigger', 'none');
- fs.writeFileSync(LED0+'/brightness', '0');
- let led0_is_on = false; // initial state
- function toggle_led0() {
- if( led0_is_on ) {
- led0_is_on = false;
- fs.writeFileSync(LED0+'/brightness', '0');
- } else {
- led0_is_on = true;
- fs.writeFileSync(LED0+'/brightness', '255');
- }
- }
- setInterval(toggle_led0, 1000); // call toggle_led0() every second
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement