Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DDR_N (DDRB)
- #define PORT_N (PORTB)
- #define PIN_N (4)
- #define BIT_SET (1 << PIN_N)
- #define BIT_CLR (B00000000)
- #define PIXELS 16
- unsigned char g = 0;
- unsigned char r = 0;
- unsigned char b = 10;
- inline void T1H() { //12
- asm volatile (
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- //"nop \n\t"
- );
- }
- inline void T1L() { //8
- asm volatile (
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- //"nop \n\t"
- );
- }
- inline void T0H() { //4
- asm volatile (
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- //"nop \n\t"
- );
- }
- inline void T0L() { //12
- asm volatile (
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- "nop \n\t"
- //"nop \n\t"
- );
- }
- inline void sendByte(unsigned char b) {
- for (int bn = 7; bn >= 0; bn--) {
- if (b & 1 << bn) {
- PORT_N = BIT_SET;
- T1H();
- PORT_N = BIT_CLR;
- T1L();
- } else {
- PORT_N = BIT_SET;
- T0H();
- PORT_N = BIT_CLR;
- T0L();
- }
- }
- }
- void setup() {
- DDR_N = BIT_SET;
- for (int i = 0; i < PIXELS; i++) {
- sendByte(g);
- sendByte(r);
- sendByte(b);
- }
- delayMicroseconds(7);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement