Skip to content

Commit

Permalink
add RGB intensity example
Browse files Browse the repository at this point in the history
  • Loading branch information
Resseguie committed Jul 3, 2015
1 parent 154b74b commit 99faadf
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [LED - RGB](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb.md)
- [LED - RGB (Common Anode)](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-anode.md)
- [LED - RGB (Common Anode) PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-anode-PCA9685.md)
- [LED - RGB Intensity](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rgb-intensity.md)
- [LED - Rainbow](https://github.com/rwaldron/johnny-five/blob/master/docs/led-rainbow.md)
- [LED - Digital Clock](https://github.com/rwaldron/johnny-five/blob/master/docs/led-digits-clock.md)
- [LED - Matrix](https://github.com/rwaldron/johnny-five/blob/master/docs/led-matrix.md)
Expand Down
89 changes: 89 additions & 0 deletions docs/led-rgb-intensity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--remove-start-->

# LED - RGB Intensity

<!--remove-end-->


Demonstrates changing intensity of an RGB LED. Requires RGB LED on pins that support PWM (usually denoted by ~).





##### RGB LED. (Arduino UNO)


Basic example with RGB LED connected to pins 6, 5, and 3 for red, green, and blue respectively.


![docs/breadboard/led-rgb.png](breadboard/led-rgb.png)<br>

Fritzing diagram: [docs/breadboard/led-rgb.fzz](breadboard/led-rgb.fzz)

&nbsp;




Run with:
```bash
node eg/led-rgb-intensity.js
```


```javascript
var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

// Initialize the RGB LED
var led = new five.Led.RGB([6,5,3]);

// Set to full intensity red
console.log("100% red");
led.color("#FF0000");


// After 3 seconds, dim to 30% intensity
setTimeout(function() {
console.log("30% red");
led.intensity(30);

// 3 secs then turn blue, still 30% intensity
setTimeout(function() {
console.log("30% blue");
led.color("#0000FF");

// Another 3 seconds, go full intensity blue
setTimeout(function() {
console.log("100% blue");
led.intensity(100);
}, 3000);

}, 3000);

}, 3000);

});
```








&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.
Copyright (c) 2014, 2015 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->
34 changes: 34 additions & 0 deletions eg/led-rgb-intensity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var five = require("../lib/johnny-five.js");
var board = new five.Board();

board.on("ready", function() {

// Initialize the RGB LED
var led = new five.Led.RGB([6,5,3]);

// Set to full intensity red
console.log("100% red");
led.color("#FF0000");


// After 3 seconds, dim to 30% intensity
setTimeout(function() {
console.log("30% red");
led.intensity(30);

// 3 secs then turn blue, still 30% intensity
setTimeout(function() {
console.log("30% blue");
led.color("#0000FF");

// Another 3 seconds, go full intensity blue
setTimeout(function() {
console.log("100% blue");
led.intensity(100);
}, 3000);

}, 3000);

}, 3000);

});
10 changes: 9 additions & 1 deletion tpl/programs.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
{"name": "led-rgb", "title": "RGB LED. (Arduino UNO)", "description": "Basic example with RGB LED connected to pins 6, 5, and 3 for red, green, and blue respectively."}
]
},
{
{
"file": "led-rgb-anode.js",
"title": "LED - RGB (Common Anode)",
"description": "Demonstrates use of an RGB LED (common anode) by setting its color to red (`#ff0000`) and making it blink. Requires RGB LED on pins that support PWM (usually denoted by ~).",
Expand All @@ -181,6 +181,14 @@
"title": "LED - RGB (Common Anode) PCA9685",
"description": "Demonstrates use of an RGB LED (common anode) with the PCA9685 controller by setting its color to red (`#ff0000`) and making it blink."
},
{
"file": "led-rgb-intensity.js",
"title": "LED - RGB Intensity",
"description": "Demonstrates changing intensity of an RGB LED. Requires RGB LED on pins that support PWM (usually denoted by ~).",
"breadboards": [
{"name": "led-rgb", "title": "RGB LED. (Arduino UNO)", "description": "Basic example with RGB LED connected to pins 6, 5, and 3 for red, green, and blue respectively."}
]
},
{
"file": "led-rainbow.js",
"title": "LED - Rainbow",
Expand Down

0 comments on commit 99faadf

Please sign in to comment.