Skip to content

Instantly share code, notes, and snippets.

@donghee
Last active April 6, 2017 02:11
Show Gist options
  • Save donghee/3447220 to your computer and use it in GitHub Desktop.
Save donghee/3447220 to your computer and use it in GitHub Desktop.
ws2801 simple version for mbed
#include "mbed.h"
DigitalOut cki(p6);
DigitalOut sdi(p5);
int i;
int main(){
while(1){
cki=0;
wait_ms(1);
// RED
for(i=0;i<8;i++){
cki=0;
sdi=0;
wait_ms(0.1);
cki=1;
wait_ms(0.1);
}
// GREEN
for(i=8;i<16;i++){
cki=0;
sdi=1;
wait_ms(0.1);
cki=1;
wait_ms(0.1);
}
// BLUE
for(i=16;i<24;i++){
cki=0;
sdi=1;
wait_ms(0.1);
cki=1;
wait_ms(0.1);
}
cki=0;
wait_ms(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment