Skip to content

Instantly share code, notes, and snippets.

@steverob
Last active January 1, 2016 10:49
Show Gist options
  • Save steverob/8133832 to your computer and use it in GitHub Desktop.
Save steverob/8133832 to your computer and use it in GitHub Desktop.
Automatically adjust Ubuntu monitor brightness based on Ambient lighting
var five = require("johnny-five"),
board, photoresistor;
var exec = require('child_process').exec;
board = new five.Board();
board.on("ready", function() {
// Create a new `photoresistor` hardware instance.
photoresistor = new five.Sensor({
pin: "A0",
freq: 1000
});
// "data" get the current reading from the photoresistor
photoresistor.on("data", function() {
percent = (this.value/1024) * 100
console.log("Setting Brightness to: ", percent);
//uses this tool xbacklight to set brightness
exec("xbacklight -set " + percent);
});
});
@steverob
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment