Merge pull request #127 from bennuttall/ledborg
Add GPIO Zero code examples to LedBorg
This commit is contained in:
commit
70082c7d36
@ -39,26 +39,28 @@ pin:
|
|||||||
-->
|
-->
|
||||||
# LedBorg
|
# LedBorg
|
||||||
|
|
||||||
The PiBorg LedBorg is an ultra-bright RGB LED board for the Raspberry Pi. It has its own driver, so you don't need to drive it manually.
|
The PiBorg LedBorg is an ultra-bright RGB LED board for the Raspberry Pi.
|
||||||
|
|
||||||
If you want a much, much wider range of colours, though, you can drive it manually using softPwm in WiringPi. The pin assignments for this are as follows:
|
|
||||||
|
|
||||||
WiringPi pin 0: Red LED
|
|
||||||
WiringPi pin 2: Green LED
|
|
||||||
WiringPi pin 3: Blue LED
|
|
||||||
|
|
||||||
This is easy using WiringPi in Python:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import wiringpi2 as wiringpi
|
from gpiozero import LedBorg
|
||||||
wiringpi.wiringPiSetup()
|
from time import sleep
|
||||||
|
|
||||||
wiringpi.softPwmCreate(0,0,100)
|
lb = LedBorg()
|
||||||
wiringpi.softPwmCreate(2,0,100)
|
|
||||||
wiringpi.softPwmCreate(3,0,100)
|
|
||||||
|
|
||||||
# Purple!
|
while True:
|
||||||
wiringpi.softPwmWrite(3,100) # Full Blue
|
r, g, b = 0, 0, 0
|
||||||
wiringpi.softPwmWrite(0,100) # Full Red
|
for i in range(100):
|
||||||
wiringpi.softPWMWrite(2,0) # No Green
|
r = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
|
for i in range(100):
|
||||||
|
g = i / 100
|
||||||
|
sleep(0.01)
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
for i in range(100):
|
||||||
|
b = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs](http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ledborg)
|
||||||
|
@ -28,29 +28,30 @@ pin:
|
|||||||
active: alto (encendido)
|
active: alto (encendido)
|
||||||
description: LED Azul PiBorg
|
description: LED Azul PiBorg
|
||||||
-->
|
-->
|
||||||
###El PiBorg LedBord es una placa con un LED RGB ultra-brillante para la Rasberry Pi.
|
### PiBorg LedBorg
|
||||||
|
|
||||||
PiBorg tiene su propio controlador, así que no necesitas controlarlo manualmente.
|
|
||||||
|
|
||||||
Si quieres un mucho, mucho mayor rango de colores, puedes controlarlo manualmente utilizando softPwm en WiringPi. Los pines para esto son los siguientes:
|
|
||||||
|
|
||||||
WiringPi pin 0: LED Rojo
|
|
||||||
WiringPi pin 2: LED Verde
|
|
||||||
WiringPi pin 3: LED Azul
|
|
||||||
|
|
||||||
Esto es fácil usando WiringPi en Python:
|
|
||||||
|
|
||||||
|
El LedBorg es una placa con un LED RGB ultra-brillante para la Rasberry Pi.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import wiringpi2 as wiringpi
|
from gpiozero import LedBorg
|
||||||
wiringpi.wiringPiSetup()
|
from time import sleep
|
||||||
|
|
||||||
wiringpi.softPwmCreate(0,0,100)
|
lb = LedBorg()
|
||||||
wiringpi.softPwmCreate(2,0,100)
|
|
||||||
wiringpi.softPwmCreate(3,0,100)
|
|
||||||
|
|
||||||
# Violeta!
|
while True:
|
||||||
wiringpi.softPwmWrite(3,100) # Azul al máximo
|
r, g, b = 0, 0, 0
|
||||||
wiringpi.softPwmWrite(0,100) # Rojo al máximo
|
for i in range(100):
|
||||||
wiringpi.softPWMWrite(2,0) # No verde
|
r = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
|
for i in range(100):
|
||||||
|
g = i / 100
|
||||||
|
sleep(0.01)
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
for i in range(100):
|
||||||
|
b = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs](http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ledborg)
|
||||||
|
@ -28,28 +28,30 @@ pin:
|
|||||||
active: high
|
active: high
|
||||||
description: LED bleue de la PiBorg
|
description: LED bleue de la PiBorg
|
||||||
-->
|
-->
|
||||||
###La carte PiBorg LedBorg ajoute une LED tricolore RGB à votre Raspberry Pi.
|
### PiBorg LedBorg
|
||||||
|
|
||||||
La carte LedBorg prend en charge la gestion de la LED. Cependant, si vous désirez contrôler le gamut de couleurs de manière plus précise, vous pouvez vous tourner vers WiringPi et son softPwn.
|
La carte PiBorg LedBorg ajoute une LED tricolore RGB à votre Raspberry Pi.
|
||||||
|
|
||||||
Pour ce faire, sachez que les broches WiringPi concernées sont les suivantes:
|
|
||||||
|
|
||||||
WiringPi broche 0: LED rouge
|
|
||||||
WiringPi broche 2: LED verte
|
|
||||||
WiringPi broche 3: LED bleue
|
|
||||||
|
|
||||||
Voici un exemple WiringPi sous Python:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import wiringpi2 as wiringpi
|
from gpiozero import LedBorg
|
||||||
wiringpi.wiringPiSetup()
|
from time import sleep
|
||||||
|
|
||||||
wiringpi.softPwmCreate(0,0,100)
|
lb = LedBorg()
|
||||||
wiringpi.softPwmCreate(2,0,100)
|
|
||||||
wiringpi.softPwmCreate(3,0,100)
|
|
||||||
|
|
||||||
# Pour du violet:
|
while True:
|
||||||
wiringpi.softPwmWrite(0,100) # max rouge
|
r, g, b = 0, 0, 0
|
||||||
wiringpi.softPwmWrite(3,100) # max bleu
|
for i in range(100):
|
||||||
wiringpi.softPWMWrite(2,0) # pas de vert
|
r = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
|
for i in range(100):
|
||||||
|
g = i / 100
|
||||||
|
sleep(0.01)
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
for i in range(100):
|
||||||
|
b = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs](http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ledborg)
|
||||||
|
@ -28,30 +28,30 @@ pin:
|
|||||||
active: high
|
active: high
|
||||||
description: PiBorg LED blu
|
description: PiBorg LED blu
|
||||||
-->
|
-->
|
||||||
###Il PiBorg LedBorg è un LED RGB ultra-luminoso per il Raspberry Pi.
|
# PiBorg LedBorg
|
||||||
|
|
||||||
PiBorg ha il suo driver, quindi non devi controllarlo manualmente.
|
|
||||||
|
|
||||||
Se vuoi una gamma di colori decisamente più ampia tuttavia, puoi controllarlo manualmente
|
|
||||||
usando softPwm su WiringPi. L'assegnazione dei pin è come segue:
|
|
||||||
|
|
||||||
* WiringPi pin 0: LED rosso
|
|
||||||
* WiringPi pin 2: LED verde
|
|
||||||
* WiringPi pin 3: LED blu
|
|
||||||
|
|
||||||
È facile usando WiringPi con Python:
|
|
||||||
|
|
||||||
|
Il PiBorg LedBorg è un LED RGB ultra-luminoso per il Raspberry Pi.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import wiringpi2 as wiringpi
|
from gpiozero import LedBorg
|
||||||
wiringpi.wiringPiSetup()
|
from time import sleep
|
||||||
|
|
||||||
wiringpi.softPwmCreate(0,0,100)
|
lb = LedBorg()
|
||||||
wiringpi.softPwmCreate(2,0,100)
|
|
||||||
wiringpi.softPwmCreate(3,0,100)
|
|
||||||
|
|
||||||
# Viola!
|
while True:
|
||||||
wiringpi.softPwmWrite(3,100) # Blu al massimo
|
r, g, b = 0, 0, 0
|
||||||
wiringpi.softPwmWrite(0,100) # Rosso al massimo
|
for i in range(100):
|
||||||
wiringpi.softPWMWrite(2,0) # Verde spento
|
r = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
|
for i in range(100):
|
||||||
|
g = i / 100
|
||||||
|
sleep(0.01)
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
for i in range(100):
|
||||||
|
b = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs](http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ledborg)
|
||||||
|
@ -28,28 +28,30 @@ pin:
|
|||||||
active: high
|
active: high
|
||||||
description: PiBorg Blue LED
|
description: PiBorg Blue LED
|
||||||
-->
|
-->
|
||||||
###PiBorg LedBorg RGB LED Board
|
# PiBorg LedBorg
|
||||||
|
|
||||||
[PiBorg LedBorg](http://www.piborg.org/ledborg/), Raspberry Pi için oldukça hafif bir RGB LED board'udur. Bu board kendisine ait bir sürücü barındırır, bu yüzden ayrıca bir sürücü kurmanıza gerek yok.
|
PiBorg LedBorg, Raspberry Pi için oldukça hafif bir RGB LED board'udur. Bu board kendisine ait bir sürücü barındırır, bu yüzden ayrıca bir sürücü kurmanıza gerek yok.
|
||||||
|
|
||||||
Eğer daha fazla aralıkta renk istiyorsanız bunu WiringPi ile softPwm ile de yapabilirsiniz. Pin atamaları şu şekilde:
|
|
||||||
|
|
||||||
WiringPi pin 0: Kırmızı LED
|
|
||||||
WiringPi pin 2: Yeşil LED
|
|
||||||
WiringPi pin 3: Mavi LED
|
|
||||||
|
|
||||||
Python ile bunu yapmak neredeyse çocuk oyuncağı:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import wiringpi2 as wiringpi
|
from gpiozero import LedBorg
|
||||||
wiringpi.wiringPiSetup()
|
from time import sleep
|
||||||
|
|
||||||
wiringpi.softPwmCreate(0,0,100)
|
lb = LedBorg()
|
||||||
wiringpi.softPwmCreate(2,0,100)
|
|
||||||
wiringpi.softPwmCreate(3,0,100)
|
|
||||||
|
|
||||||
# mor!
|
while True:
|
||||||
wiringpi.softPwmWrite(3,100) # Full Blue
|
r, g, b = 0, 0, 0
|
||||||
wiringpi.softPwmWrite(0,100) # Full Red
|
for i in range(100):
|
||||||
wiringpi.softPWMWrite(2,0) # No Green
|
r = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
|
for i in range(100):
|
||||||
|
g = i / 100
|
||||||
|
sleep(0.01)
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
for i in range(100):
|
||||||
|
b = i / 100
|
||||||
|
lb.value = (r, g, b)
|
||||||
|
sleep(0.01)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[GPIO Zero docs](http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ledborg)
|
||||||
|
Loading…
Reference in New Issue
Block a user