I am using NucleoF103rb and sending data to APA102 led which is 10x10 matrix of microcontroller LEDs via SPI using mbed online compiler. I am sending start frame, data and end frame. With “0xff00”, I am trying to light up the LEDs with red color which works well. I have two questions: 1. I would like to understand how I can control the brightness level of the LEDs. 2. Also, I tried changing the color to blue with the line: “spi.write(0xff0000);” , however, the LEDs are turning white. Do I have to code spi.write thrice with RGB values? Any help/idea would be much appreciated.
include "mbed.h"
define LED_FREQ 2000000
SPI spi(PB_5, PB_4, PB_3);
uint8_t sendByte() { for (int counter=0;counter<8;counter++) { how to control brightness of LED? spi.write(0xff00); }
return 1; }
int sendStartFrame(int numBytes = 4) { for (int i = 0; i < numBytes; i ++) { spi.write(0); }
return 1; }
int sendEndFrame(int numBytes = 4) { for (int i = 0; i < 4; i ++) { spi.write(1); }
return 1; }
int main() {
spi.frequency(LED_FREQ);
sendStartFrame();
for (uint8_t x = 0; x < 16; x++) {
for (uint8_t y = 0; y < 16; y++) {
sendByte();
}
}
sendEndFrame();
}