Skip to content

Instantly share code, notes, and snippets.

@jadonk
Forked from DiegoTc/CARD_0.html
Created Aug 21, 2014
Embed
What would you like to do?
Bone101 Tutorial
<span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 30px; line-height: 30px;">Overview<br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">In this tutorial, you will learn how to control the color of an RGB LED using a BeagleBone Black (BBB).<br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 30px; line-height: 30px;"><img src="https://learn.adafruit.com/system/assets/assets/000/009/503/medium800/beaglebone_overview_web.jpg?1396892026" style="width: 403px;"><br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">Because the BBB runs Linux, there are many ways in which it can be programmed. In this tutorial we show how to control the power output of a GPIO pin and hence control the color of an RGB LED using Python.</span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 30px; line-height: 30px;"><br></span>
<span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; line-height: 30px;"><span style="font-weight: bold;">You will need<br></span></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; line-height: 20px;"><span style="font-size: 14px;">To make the project described in this tutorial, you will need the following:</span><br><span style="font-size: 14px;"><img src="https://learn.adafruit.com/system/assets/assets/000/009/504/medium800/beaglebone_bbb.jpg?1396892042" style="width: 173.25px; height: 132.93935643564356px;">&nbsp;</span><span style="font-weight: bold; background-color: yellow;">Beagle Bone Black &nbsp;&nbsp;<img src="https://learn.adafruit.com/system/assets/assets/000/009/505/medium800/beaglebone_rgb_cc_10mm_web.jpg?1396892053" style="width: 114px; height: 107.5593220338983px;"></span></span><span style="font-weight: bold; background-color: yellow;"><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">Diffused 10mm&nbsp;RGB LED common&nbsp;</span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">cathode&nbsp;</span></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;"><br><img src="https://learn.adafruit.com/system/assets/assets/000/009/506/medium800/beaglebone_R-470-level.jpg?1396892067" style="width: 201.5px;"></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px; font-weight: bold; background-color: yellow;">3 x appox. 470Ω resistors&nbsp;</span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">&nbsp;<img src="https://learn.adafruit.com/system/assets/assets/000/009/507/medium800/beaglebone_breadboard_half_web.jpg?1396892080" style="width: 148.75px; height: 102.86691542288557px;">&nbsp;</span><span style="font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px; font-weight: bold; background-color: yellow; background-position: initial;">Half-sized Breadboard</span><span style="font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;"><span style="font-weight: bold; background-color: yellow;">&nbsp;&nbsp; </span><span style="color: rgb(51, 51, 51);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></span><div><span style="font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;"><span style="color: rgb(51, 51, 51);"><img src="https://learn.adafruit.com/system/assets/assets/000/009/508/medium800/beaglebone_jumpers_web.jpg?1396892092" style="width: 201.5px;"></span><span style="font-weight: bold; background-color: yellow;">Male to male jumper leads</span><br></span></div>
<span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 30px; line-height: 30px;">Wiring (Common Cathode LED)<br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">Wire up the breadboard using the header leads as shown below.<br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 30px; line-height: 30px;"><img src="https://learn.adafruit.com/system/assets/assets/000/009/509/medium800/beaglebone_fritzing.png?1396892133" style="width: 403px;"><br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">Push the LED leads into the breadboard, with the longest (common negative) lead on the second row of the breadboard. It does not matter which way around the resistors go.<br></span><span style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">The top two connections on the BBB expansion header we are using (P8) are both GND. The three outputs to control the brightness of the red, green and blue channels are connected to sockets P8_13, P8_19 and P9_14 of the BBB.</span><br style="color: rgb(51, 51, 51); font-family: 'Gotham SSm A', 'Gotham SSm B'; font-size: 14px; line-height: 20px;">
import Adafruit_BBIO.PWM as PWM
import time
red = "P8_13"
green = "P8_19"
blue = "P9_14"
PWM.start(red, 0)
PWM.start(blue, 0)
PWM.start(green, 0)
def fade(colorA, colorB, ignore_color):
PWM.set_duty_cycle(ignore_color, 100)
for i in range(0, 100):
PWM.set_duty_cycle(colorA, i)
PWM.set_duty_cycle(colorB, 100-i)
time.sleep(0.05)
while True:
fade(red, green, blue)
fade(green, blue, red)
fade(blue, red, green)
<h5 style="font-family: 'Gotham SSm A', 'Gotham SSm B'; line-height: 20px; color: rgb(0, 0, 0); margin: 0px; font-size: 16px; padding-bottom: 5px;"><span style="color: rgb(0, 172, 236); background-position: initial;"><img src="https://learn.adafruit.com/system/guides/images/000/000/322/medium310/overview_web.jpg?1396718777" style="width: 320px; float: right;"><br>Fading a RGB LED on BeagleBone Black<br><span style="color: rgb(51, 51, 51); font-size: 13px; line-height: 18.571430206298828px; background-color: rgb(255, 255, 255); background-position: initial; font-weight: bold;">Learn how to control the color of an RGB LED<br></span><span style="color: rgb(51, 51, 51); font-size: 12px; line-height: 17.142858505249023px; background-color: rgb(255, 255, 255); background-position: initial;">In this tutorial, you will learn how to control the color of an RGB LED using a BeagleBone Black and Python.</span><br></span></h5>
Preview Card 1
Overview
You will need
Wiring
Writing a program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment