Created
October 20, 2016 11:48
-
-
Save miawgogo/bf8937e0d86cf20723ca30c9cbe2cac9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int meter = 11; // blue LED in Digital Pin 9 (PWM) | |
| int old = 0; | |
| void setup(){ | |
| Serial.begin(9600); | |
| pinMode(meter,OUTPUT); // tell arduino it's an output | |
| // test and set all the outputs to low | |
| digitalWrite(meter,LOW); | |
| } | |
| void loop(){ | |
| int msg; | |
| msg = int(Serial.read()); | |
| int x = msg; | |
| if (x == -1){return;} | |
| analogWrite(meter,x);old=x;Serial.println(x,HEX); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from linux_metrics import cpu_stat | |
| import serial | |
| import time | |
| port = serial.Serial('/dev/ttyACM0', 9600) | |
| while True: | |
| idle = cpu_stat.cpu_percents() | |
| idle = idle['idle']/100 | |
| val = 255 * (1-idle) | |
| val = int(str(val).split('.')[0]) | |
| print(val) | |
| port.write(bytes(val)) | |
| time.sleep(0.25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment