Home Code mbed LPC1768 RGB led example

mbed LPC1768 RGB led example

by shedboy71

This was an RGB Led breakout example connected to our mbed LPC1768 board, we used a common anode type. here is a picture of the module, you could of course use an RGB led and 3 resistors instead

rgb led module

rgb led module

Red connected to Pin 23
Green connected to pin 22
Blue connected to pin 21

mbed LPC1768 pinout

mbed LPC1768 pinout

The code example simply cycles through the 3 colours

Code

 

[codesyntax lang=”cpp”]

#include "mbed.h"

DigitalOut redLed(p23);
DigitalOut greenLed(p22);
DigitalOut blueLed(p21);

int main()
{
while(1)
{
redLed = 0;
greenLed = 1;
blueLed = 1;
wait(1);
redLed = 1;
greenLed = 0;
blueLed = 1;
wait(1);
redLed = 1;
greenLed = 1;
blueLed = 0;
wait(1);
}
}

[/codesyntax]

 

Links

mbed – LPC1768 Development Board at Amazon US

mbed – LPC1768 Development Board

Share

You may also like