Last active
January 1, 2016 10:49
-
-
Save steverob/8133832 to your computer and use it in GitHub Desktop.
Automatically adjust Ubuntu monitor brightness based on Ambient lighting
This file contains 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
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); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Circuit Diagram
http://i.imgur.com/hqdx8Vn.png