Advertisement
Guest User

Untitled

a guest
Jul 25th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/node
  2.  
  3. const fs = require('fs');
  4.  
  5. const LED0 = "/sys/class/leds/beaglebone:green:usr0";
  6.  
  7. // initialize LED0
  8. fs.writeFileSync(LED0+'/trigger', 'none');
  9. fs.writeFileSync(LED0+'/brightness', '0');
  10.  
  11. let led0_is_on = false;  // initial state
  12.  
  13. function toggle_led0() {
  14.     if( led0_is_on ) {
  15.         led0_is_on = false;
  16.         fs.writeFileSync(LED0+'/brightness', '0');
  17.     } else {
  18.         led0_is_on = true;
  19.         fs.writeFileSync(LED0+'/brightness', '255');
  20.     }
  21. }
  22.  
  23. setInterval(toggle_led0, 1000);  // call toggle_led0() every second
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement