SHOW:
|
|
- or go back to the newest paste.
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(LED1+'/trigger', 'none'); |
8 | + | fs.writeFileSync(LED0+'/trigger', 'none'); |
9 | - | fs.writeFileSync(LED1+'/brightness', '0'); |
9 | + | fs.writeFileSync(LED0+'/brightness', '0'); |
10 | ||
11 | let led1_is_on = false; // initial state | |
12 | ||
13 | function toggle_led0() { | |
14 | if( led1_is_on ) { | |
15 | led1_is_on = false; | |
16 | fs.writeFileSync(LED0+'/brightness', '0'); | |
17 | } else { | |
18 | led1_is_on = true; | |
19 | fs.writeFileSync(LED0+'/brightness', '255'); | |
20 | } | |
21 | } | |
22 | ||
23 | setInterval(toggle_led0, 1000); // call toggle_led0() every second |