Home STM32STM32 Code ST Nucleo F334R8 RGB led example

ST Nucleo F334R8 RGB led example

This is  a first example with the ST Nucleo F334R8 board, this uses the mbed online compiler. here is a picture of the board

ST Nucleo F334R8

ST Nucleo F334R8

In this example we flash the red, green and blue colours of an RGB led . Our RGB LED was a common anode type, so a low output switches the LED on and a high output switches the LED off. You may have to reverse this.

Code

[codesyntax lang=”cpp”]

#include "mbed.h"
 
DigitalOut red(D5);
DigitalOut blue(D8);
DigitalOut green(D9);
 
int main() 
{
    while(1) 
    {
        red = 0; //red on
        wait(1.0); // 1 sec
        red = 1; //red off
        green = 0; //green on
        wait(1.0); // 1 sec
        green = 1; //green off
        blue = 0; //blue on
        wait(1.0); // 1 sec
        blue = 1; // blue off
    }
}

[/codesyntax]

 

Links
Waveshare STM32 Board Nucleo NUCLEO-F334R8 STM32F334R8 STM32 Development Board Integrate ST-LINK/V2-1 Debugger/Programmer Support Arduino