63 lines
1.9 KiB
Arduino
63 lines
1.9 KiB
Arduino
|
/*
|
||
|
#include <stdint.h>
|
||
|
uint8_t dataPin = 13;
|
||
|
uint8_t red = 200;
|
||
|
uint8_t green = 200;
|
||
|
uint8_t blue = 200;
|
||
|
|
||
|
// f=16MHz -> T=0,0625µs
|
||
|
uint8_t T0H = 5; // == 0.3125µs ~ 0.4 µs (+- 150ns) == [0.25, 0.55] µs
|
||
|
uint8_t T1H = 11; // == 0.6875µs ~ 0.8 µs (+- 150ns) == [0.65, 0.95] µs
|
||
|
uint8_t T0L = 12; // == 0.7500µs ~ 0.85µs (+- 150ns) == [0.70, 1.00] µs
|
||
|
uint8_t T1L = 6; // == 0.3750µs ~ 0.45µs (+- 150ns) == [0.30, 0.60] µs
|
||
|
uint8_t RES = 51; // > 50 µs
|
||
|
*/
|
||
|
#define dataPin 13
|
||
|
|
||
|
#define red 0
|
||
|
#define green 0
|
||
|
#define blue 255
|
||
|
|
||
|
#define ONE ({digitalWrite(dataPin, HIGH); wait5; digitalWrite(dataPin, LOW); wait12;})
|
||
|
#define ZER ({digitalWrite(dataPin, HIGH); wait11; digitalWrite(dataPin, LOW); wait6;})
|
||
|
#define RESET ({digitalWrite(dataPin, LOW); delayMicroseconds(51);})
|
||
|
|
||
|
#define wait5 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||
|
#define wait6 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||
|
#define wait11 __asm__("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")
|
||
|
#define wait12 __asm__("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")
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
pinMode(dataPin, OUTPUT);
|
||
|
digitalWrite(dataPin, LOW);
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
(red & B1000000) ? ONE : ZER;
|
||
|
(red & B0100000) ? ONE : ZER;
|
||
|
(red & B0010000) ? ONE : ZER;
|
||
|
(red & B0001000) ? ONE : ZER;
|
||
|
(red & B0000100) ? ONE : ZER;
|
||
|
(red & B0000010) ? ONE : ZER;
|
||
|
(red & B0000001) ? ONE : ZER;
|
||
|
(green & B1000000) ? ONE : ZER;
|
||
|
(green & B0100000) ? ONE : ZER;
|
||
|
(green & B0010000) ? ONE : ZER;
|
||
|
(green & B0001000) ? ONE : ZER;
|
||
|
(green & B0000100) ? ONE : ZER;
|
||
|
(green & B0000010) ? ONE : ZER;
|
||
|
(green & B0000001) ? ONE : ZER;
|
||
|
(blue & B1000000) ? ONE : ZER;
|
||
|
(blue & B0100000) ? ONE : ZER;
|
||
|
(blue & B0010000) ? ONE : ZER;
|
||
|
(blue & B0001000) ? ONE : ZER;
|
||
|
(blue & B0000100) ? ONE : ZER;
|
||
|
(blue & B0000010) ? ONE : ZER;
|
||
|
(blue & B0000001) ? ONE : ZER;
|
||
|
RESET;
|
||
|
}
|
||
|
|
||
|
|