silver2row

Some ole fashioned Linux NO-de.js

Jul 25th, 2021
945
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/node
  2.  
  3. ////////////////////////////////////////
  4. //      blinkLED.js
  5. //      Blinks the USR LEDs and P9_14.
  6. //      Wiring: P9_14 connects to the plus lead of an LED.  The negative lead of the
  7. //                      LED goes to a 220 Ohm resistor.  The other lead of the resistor goes
  8. //                      to ground.
  9. //      Setup:
  10. //      See:
  11. ////////////////////////////////////////
  12. const fs = require('fs');
  13.  
  14. let LED1 = "/sys/class/leds/beaglebone:green:usr0/brightness";
  15. //const LED2 = "/sys/class/leds/beaglebone:green:usr1";
  16. //const LED3 = "/sys/class/leds/beaglebone:green:usr2";
  17. //const LED4 = "/sys/class/leds/beaglebone:green:usr3";
  18. //const LED5 = "/sys/class/leds/beaglebone:green:usr4";
  19.  
  20. // var brightness = [ "/sys/class/leds/beaglebone:green:usr0/brightness", "/sys/class/leds/beaglebone:green:usr1/brightness",
  21. //                   "/sys/class/leds/beaglebone:green:usr2/brightness", "/sys/class/leds/beaglebone:green:usr3/brightness",
  22. //                   "/sys/class/leds/beaglebone:green:usr4/brightness" ];
  23.  
  24. setInterval(perk, 10000);
  25.  
  26. function perk() {
  27.   while(1) {
  28.     fs.writeFileSync(LED1, '1', function (err) {
  29.       if (err) return console.log(err);
  30.       console.log('1 > LED1');
  31.     })
  32.  
  33.     fs.writeFileSync(LED1, '0', function (err) {
  34.       if (err) return console.log(err);
  35.       console.log('0 > LED1');
  36.     })
  37.   }
  38. }
RAW Paste Data