Creates a scale for the value of the lightSensor to follow.
onBoardEvent(lightSensor, "data", function(event) {
lightSensor.setScale(0, 255);
var light1 = lightSensor.value;
lightSensor.setScale(100, 255);
var light2 = lightSensor.value;
lightSensor.setScale(0, 255);
var light3 = lightSensor.value;
setProperty("screen1", "background-color", rgb(light1,light2,light3));
});
var redness;
lightSensor.setScale(0, 255);
timedLoop(100, function() {
redness = Math.round(lightSensor.value);
setProperty("screen1", "background-color", rgb(redness, 0, 0));
});
lightSensor.setScale(low, high);
| Name | Type | Required? | Description |
|---|---|---|---|
| low | number | The low value to start the scale at. | |
| high | number | The high value to end the scale at. |
Found a bug in the documentation? Let us know at documentation@code.org