-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# A standard 3 pin RGB LED (not single pin addressable), on 3 PWM pins. | ||
# | ||
require 'bundler/setup' | ||
require 'denko' | ||
|
||
RED_PIN = 11 | ||
GREEN_PIN = 10 | ||
BLUE_PIN = 9 | ||
|
||
board = Denko::Board.new(Denko::Connection::Serial.new) | ||
rgb_led = Denko::LED::RGB.new board: board, | ||
pins: {red: RED_PIN, green: GREEN_PIN, blue: BLUE_PIN} | ||
|
||
# Set these predefined colors with symbols. | ||
[:red, :green, :blue, :cyan, :yellow, :magenta, :white, :off].each do |color| | ||
rgb_led.color = color | ||
sleep 0.5 | ||
end | ||
|
||
# Set duty cycle for each "sub LED". | ||
loop do | ||
rgb_led.red.duty = 100 | ||
rgb_led.green.duty = 50 | ||
rgb_led.blue.duty = 0 | ||
sleep 0.5 | ||
rgb_led.red.duty = 100 | ||
rgb_led.green.duty = 0 | ||
rgb_led.blue.duty = 50 | ||
sleep 0.5 | ||
end |
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
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
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
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
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
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
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