Home » DEVELOPERS » Tutorials » Manage the leds

 Developers>Tutoriels>Manage the leds

 

The leds on the MRPi1 robot

The MRPi1 robot has three leds on the front :

  • LED1
  • LED2
  • LED3

Turn on/off a led

  • Start the python program :
$ python

img1_led

  • import the mrpi1_lib library :

$ from mrpi1_lib import *
  • Turn on the first led :

$ led(1,1)
  • Turn on the led n°3 :
$ led(3,1)
  • Turn off the led n°3 and n°1 :
$ led(1,0)
$ led(3,0

img2_led

Toggle function

Now, we will learn to change the status of an Led .

$ ledToggle(1) # toggle led 1
$ ledToggle(3) # toggle led 3

A small led chase effect

Test this program :

from mrpi1_lib import *
import time

#main program
 print "Start program"

while 1:
 led(1,1) 
 time.sleep(1)
 led(2,1)
 led(3,1)
 time.sleep(1)
 led(1,0)
 led(2,0)
 led(3,0)
 time.sleep(1)