Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Duration in milliseconds for each symbol
- #define DEL 420
- // Transmit a digital zero / LOW
- #define TXNULL digitalWrite(data, HIGH); delayMicroseconds(DEL); digitalWrite(data, LOW); delayMicroseconds(DEL*3);
- // Transmit a digital one / HIGH
- #define TXONE digitalWrite(data, HIGH); delayMicroseconds(DEL*3); digitalWrite(data, LOW); delayMicroseconds(DEL);
- // Pins for CHJ-FST1000M
- int gnd = 10;
- int vcc = 11;
- int data = 12;
- // On-board LED for debugging
- int led = 13;
- unsigned char msg_a[] = { 0b00000001, 0b01010101, 0b00001100 };
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0x88, 0x88, 0x88, 0x80 };
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0x88, 0x88, 0xee, 0x80 }; // REDDOOOOO
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0x88, 0xee, 0x88, 0x80 }; // BLUEEEEO
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0x88, 0xee, 0xee, 0x88 }; // GREENOOO
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0xee, 0x88, 0x88, 0x80 }; // PINKIE
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0xee, 0x88, 0xee, 0x80 }; // YELLOW
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0xee, 0xee, 0x88, 0x80 }; // TURQUOIOUIOUISE
- //unsigned char msg_a[] = { 0x88, 0x88, 0x88, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x88, 0xee, 0xee, 0xee, 0x88 }; // WHITE-O
- unsigned char *message;
- void setup() {
- pinMode(vcc, OUTPUT);
- pinMode(data, OUTPUT);
- pinMode(led, OUTPUT);
- pinMode(gnd, OUTPUT);
- pinMode(A0, INPUT_PULLUP);
- pinMode(A1, OUTPUT);
- pinMode(0, INPUT_PULLUP);
- pinMode(1, INPUT_PULLUP);
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
- pinMode(6, INPUT_PULLUP);
- pinMode(7, INPUT_PULLUP);
- digitalWrite(vcc, HIGH);
- digitalWrite(gnd, LOW);
- Serial.begin(9600);
- }
- int sent = 0, i, j, del_cnt;
- int col = 1;
- void txColor(unsigned char color) {
- digitalWrite(led, HIGH);
- for (i = 0; i < 18; i++) {
- if (msg_a[i / 8] & (1 << (7 - i % 8))) { TXONE; }
- else { TXNULL; }
- }
- for (i = 2; i >= 0; i--) {
- if (color & (1 << i)) { TXONE; TXONE; }
- else { TXNULL; TXNULL; }
- }
- digitalWrite(led, LOW);
- digitalWrite(data, LOW);
- delay(10);
- }
- void txMode(unsigned char mode) {
- digitalWrite(led, HIGH);
- for (i = 0; i < 16; i++) {
- if (msg_a[i / 8] & (1 << (7 - i % 8))) { TXONE; }
- else { TXNULL; }
- }
- TXONE; TXONE;
- for (i = 2; i >= 0; i--) {
- if (mode & (1 << i)) { TXONE; TXONE; }
- else { TXNULL; TXNULL; }
- }
- digitalWrite(led, LOW);
- digitalWrite(data, LOW);
- delay(10);
- }
- void loop() {
- Serial.println(col);
- /*
- //if (digitalRead(A0) == HIGH) {
- if (digitalRead(7) == LOW) {
- col = 0;
- }
- if (digitalRead(6) == LOW) {
- col = 1;
- }
- if (digitalRead(5) == LOW) {
- col = 2;
- }
- if (digitalRead(4) == LOW) {
- col = 3;
- }
- txMode(col); txMode(col); txMode(col);
- */
- //} else {
- txColor(col); txColor(col); txColor(col);
- col++;
- //}
- if (del_cnt == 4) { delay(150); del_cnt = 0; }
- del_cnt++;
- if (col == 8) col = 1;
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement