-
-
Save PJTewkesbury/2c0f3162309412cd42be844d983e44f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wiringPi.h> | |
#include <wiringPiSPI.h> | |
#include <iostream> | |
#include <stdint.h> | |
int main() { | |
wiringPiSetup(); | |
if(wiringPiSPISetup(0, 6000000) < 0) { | |
std::cerr << "wiringPiSPISetup failed" << std::endl; | |
} | |
uint8_t buf[1]; | |
for(int i = 0; i < 4; i++) { | |
buf[0] = 0x00; | |
wiringPiSPIDataRW(0, buf, 1); | |
} | |
uint8_t r, g, b, brightness; | |
r = 0xFF; | |
g = 0x00; | |
b = 0x00; | |
brightness = 15; | |
uint8_t led_frame[4]; | |
for(int i = 0; i < 60; i++) { | |
led_frame[0] = 0b11100000 | (0b00011111 & brightness); | |
led_frame[1] = b; | |
led_frame[2] = g; | |
led_frame[3] = r; | |
wiringPiSPIDataRW(0, led_frame, 4); | |
} | |
for(int i = 0; i < 4; i++) { | |
buf[0] = 0xFF; | |
wiringPiSPIDataRW(0, buf, 1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment