This example of digital output uses a RGB LED to display cyclically, every second, the three red, green and blue colors (see Figure 2). It can be managed from the Internet via start and stop commands.
Connect the RGB LED as shown in Figure 1:
The longest PIN is the negative.
Write a sketch K to define:
r :: d5
gnd :: d6
g :: d7
b :: d8
start = [gnd=0,r=1]
stop = [r=0,g=0,b=0]
b==1 -> [b=0,r=1] ##1
g==1 -> [g=0,b=1] ##1
r==1 -> [r=0,g=1] ##1
or simply load the sketch in the workspace with the command
] load e04_rgb_led
Note: the automaton state is identified by the only LED on.
Try the following commands now:
] start
the RGB LED starts with the red, after 1 second becomes green, after 1 second becomes blue and after 1 second it resumes with the red
] pause
the LED stops
] play
the LED resumes
] stop
turns off the LED.
In this lesson you learned or repeated: