SCE5784
Připojení k Arduinu
Pin SCE5782 | Název pinu SCE5782 | Pin Arduino |
---|---|---|
1 | CLKSEL | – |
2 | Vcc | 5V |
3 | Vll | 5V |
11 | LOAD | D2 |
12 | GND | GND |
13 | GND | GND |
14 | Serial DATA | D3 |
15 | NC | – |
16 | Serial CLK | D4 |
24 | RESET | D5 |
25 | CLK I/O | – |
26 | NC | – |
Zdrojový kód pro Arduino
// sketch: http://blog.smue.org/archives/433-DBOX1-SDA5708-display-+-arduino.html // adapted sketch by niq_ro: http://arduinotehniq.blogspot.com/ #include "font.h" int wait = 0; const int LOAD = 2; const int DATA = 3; const int SDCLK = 4; const int RESET = 5; char msg[] = " SCE5782 DEMO"; void setup() { pinMode(DATA, OUTPUT); pinMode(LOAD, OUTPUT); pinMode(SDCLK, OUTPUT); pinMode(RESET, OUTPUT); init_SDA5782(); brightness_SDA5782(3); //(0 = MAX, 7 = OFF) } void loop() { for (byte i = 0; i < (sizeof(msg) / sizeof(char)); i++) { for (byte j = 0; j < 8; j++) { if (i + j < (sizeof(msg) / sizeof(char))) { digit_to_SDA5782(msg[i + j], j ); } else { digit_to_SDA5782(" ", j ); } } delay(300); } } void init_SDA5782(void) { digitalWrite(LOAD, HIGH); digitalWrite(RESET, LOW); digitalWrite(RESET, HIGH); } void digit_to_SDA5782(uint8_t sign, uint8_t digit) { uint8_t i; if ((sign < 0x20) || (sign > 0x7b)) sign = 0x20; if (digit > 7) digit = 0; send_byte_to_SDA5782(0b10100000 | digit); for (i = 0; i < 7; i++) { send_byte_to_SDA5782(pgm_read_byte(&font[(sign - 0x20) * 7 + i]) / 8); } } void send_byte_to_SDA5782(uint8_t byte) { uint8_t x; digitalWrite(LOAD, LOW); for (x = 0; x <= 7; x++) { if ((byte >> x) & 1) { digitalWrite(DATA, HIGH); } else { digitalWrite(DATA, LOW); } digitalWrite(SDCLK, HIGH); digitalWrite(SDCLK, LOW); } digitalWrite(LOAD, HIGH); } void brightness_SDA5782(uint8_t val) { send_byte_to_SDA5782(0b11100000 | (val & 0b00000111)); }