Modifications

Sauter à la navigation Sauter à la recherche
1 601 octets ajoutés ,  17 novembre 2018 à 23:11
Ligne 125 : Ligne 125 :  
rgb.black()
 
rgb.black()
 
print( "That's the end folks")</syntaxhighlight>
 
print( "That's the end folks")</syntaxhighlight>
 +
 +
Le fichier d'exemple {{fname|textfx.py}} utilise la bibliothèque complémentaire {{fname|rgbfx.py}} pour proposer des animations lumineuses.
 +
 +
<syntaxhighlight lang="python"># Effet RGB avec MOD-RGB d'Olimex avec un ESP8266 sous MicroPython
 +
#
 +
# Shop: http://shop.mchobby.be/product.php?id_product=1410
 +
# Wiki: https://wiki.mchobby.be/index.php?title=MICROPYTHON-MOD-RGB
 +
 +
from machine import I2C, Pin
 +
from time import sleep_ms
 +
from modrgb import MODRGB
 +
import rgbfx
 +
 +
i2c = I2C( sda=Pin(2), scl=Pin(4) )
 +
rgb = MODRGB( i2c ) # adresse par défaut=0x20
 +
rgb.pwm( True )
 +
 +
# Couleur en rose
 +
rose = (255, 102, 204)
 +
rgb.set_rgb( rose )
 +
sleep_ms( 1000 )
 +
 +
# Effet de chandelle
 +
rgb.pwm( True )
 +
rgbfx.candle( rgb )
 +
rgb.pwm( False )
 +
sleep_ms( 1000 )
 +
 +
# Fade-in / Fade-out
 +
rgb.pwm( True )
 +
rgbfx.fade_inout( rgb, rose )
 +
rgb.pwm( False )
 +
sleep_ms( 1000 )
 +
 +
# Roue des couleurs cyclique
 +
rgb.pwm( True )
 +
rgbfx.cycle_wheel( rgb )
 +
rgb.pwm( False )
 +
sleep_ms( 1000 )
 +
 +
# Désactivé
 +
rgb.pwm( False )
 +
print( "That's the end folks")</syntaxhighlight>
 +
 +
== Changer l'adresse I2C de la carte MOD-RGB ==
 +
L'exemple suivant montre comment changer l'adresse courante de la carte MOD-RGB (0x20) vers 0x22.
 +
 +
ATTENTION: Il faut avoir le cavalier fermé pendant l'exécution de la commande {{fname|change_address()}} .
 +
 +
<syntaxhighlight lang="python"># Modifier l'adresse de MOD-RGB d'Olimex vers 0x22
 +
#
 +
# Shop: http://shop.mchobby.be/product.php?id_product=1410
 +
 +
from machine import I2C, Pin
 +
from modrgb import MODRGB
 +
 +
i2c = I2C( sda=Pin(2), scl=Pin(4) )
 +
brd = MODRGB( i2c, addr=0x20 )
 +
brd.change_address( 0x22 )</syntaxhighlight>
 +
```
    
== Où acheter ==
 
== Où acheter ==
29 879

modifications

Menu de navigation