// hobbyprojects.com // RGB_Propeller_display_30_11_2019.ino #define RPM 1000 // Change according to your motor RPM. #define red 0x80 #define green 0x40 #define blue 0x20 #define yellow 0xC0 #define cyan 0x60 #define magenta 0xA0 #define white 0xE0 #define black 0x00 #define heart_symbol 5 int sensor_pin = 8; int input_state; PROGMEM const unsigned char number[]{ //0 B01110, B11001, B10101, B10011, B01110, // 1 B00000, B10010, B11111, B10000, B00000, // 2 B11001, B10101, B10101, B10101, B00010, // 3 B10001, B10001, B10101, B10101, B01010, // 4 B00011, B00100, B00100, B00100, B11111, // 5 B10111, B10101, B10101, B10101, B01001, // 6 B01110, B10101, B10101, B10101, B01000, // 7 B00001, B00001, B00001, B11101, B00011, // 8 B01010, B10101, B10101, B10101, B01010, // 9 B00010, B10101, B10101, B11101, B01110}; PROGMEM const unsigned char letter[]{ // A B11110, B00101, B00101, B00101, B11110, // B B11111, B10101, B10101, B10101, B01010, // C B01110, B10001, B10001, B10001, B10001, // D B11111, B10001, B10001, B10001, B01110, // E B11111, B10101, B10101, B10101, B10101, // F B11111, B00101, B00101, B00101, B00001, // G B01110, B10001, B10101, B10101, B11101, // H B11111, B00100, B00100, B00100, B11111, // I B10000, B10001, B11111, B10001, B10000, // J B01100, B10000, B10001, B11111, B00001, // K B11111, B00100, B00110, B01001, B10000, // L B11111, B10000, B10000, B10000, B10000, // M B11111, B00010, B00100, B00010, B11111, // N B11111, B00001, B01110, B10000, B11111, // O B01110, B10001, B10001, B10001, B01110, // P B11111, B00101, B00101, B00101, B00010, // Q B01110, B10001, B10001, B11110, B10000, // R B11111, B00101, B00101, B01101, B10010, // S B10010, B10101, B10101, B10101, B01001, // T B00001, B00001, B11111, B00001, B00001, // U B01111, B10000, B10000, B10000, B01111, // V B00011, B01100, B10000, B01100, B00011, // W B11111, B01000, B00100, B01000, B11111, // X B10001, B01010, B00100, B01010, B10001, // Y B00011, B00100, B11100, B00100, B00011, // Z B11001, B10101, B10101, B10101, B10011}; PROGMEM const unsigned char symbol[]{ // ◄ symbol No. 0 B00000, B00100, B01110, B11111, B00000, // ► symbol No. 1 B00000, B11111, B01110, B00100, B00000, // ▲ symbol No. 2 B01000, B01100, B01110, B01100, B01000, // ▼ symbol No. 3 B00010, B00110, B01110, B00110, B00010, // ■ symbol No. 4 B11111, B11111, B11111, B11111, B11111, // ♥ symbol No. 5 B00110, B01111, B11110, B01111, B00110}; PROGMEM const unsigned char ch_space[]{ B00000, B00000, B00000, B00000, B00000}; void setup() { DDRD = 0xFF; pinMode(sensor_pin, INPUT_PULLUP); } void loop() { input_state = digitalRead(sensor_pin); while (input_state != 0) { input_state = digitalRead(sensor_pin); } //==================================== //======== Example 1 ================= /* displayChar('K', yellow); */ //==================================== //======== Example 2 ================= /* displayChar('A', red); displayChar('B', green); displayChar('C', blue); */ //==================================== //======== Example 3 ================= /* displayChar('A', red); space(); displayChar('B', green); space(); displayChar('C', blue); */ //==================================== //======== Example 4 ================= /* displayStr("ABC", green); */ //==================================== //======== Example 5 ================= /* displayStr("TEST 123", yellow); */ //==================================== //======== Example 6 ================= /* displayStr("HELLO WORLD", white); */ //==================================== //======== Example 7 ================= /* displayStr("HELLO ", yellow); displayStr("WORLD", magenta); */ //==================================== //======== Example 8 ================= /* displaySymbol(0, red); displaySymbol(1, green); displaySymbol(2, blue); displaySymbol(3, yellow); displaySymbol(4, magenta); displaySymbol(5, cyan); */ //==================================== //======== Example 9 ================= displayChar('I', yellow); displaySymbol(heart_symbol, red); displayStr("YOU", cyan); //==================================== //======== Example 10 ================= /* displayMultiColorStr("HELLO WORLD"); */ //========================================== input_state = digitalRead(sensor_pin); while (input_state == 0) { input_state = digitalRead(sensor_pin); } } //------------------------------------------ void displayStr(String str, char color) { int i = 0; char c = 1; while(c != 0) { c = str.charAt(i); displayChar(c,color); i++; } } //------------------------------------------ void displayChar(char c, char color) { int a; byte x; if((c >= 'A') && (c <= 'Z')) { a = (c - 0x41)*5; for(int i = 0; i < 5; i++) { x = pgm_read_byte(&(letter+a)[i]); x = ~x; x &= 0x1F; x |= color; PORTD = x; delayMicroseconds(100000/RPM); // for LED pixel width PORTD = 0b00011111, // blank delayMicroseconds(600000/RPM); // for gap between the columns } delayMicroseconds(900000/RPM); // for gap between the chars } else if((c >= '0') && (c <= '9')) { a = (c - 0x30)*5; for(int i = 0; i < 5; i++) { x = pgm_read_byte(&(number+a)[i]); x = ~x; x &= 0x1F; x |= color; PORTD = x; delayMicroseconds(100000/RPM); // for LED pixel width PORTD = 0b00011111, // blank delayMicroseconds(600000/RPM); // for gap between the columns } delayMicroseconds(900000/RPM); // for gap between the chars } else if(c == ' ') space(); } //------------------------------------------ void displaySymbol(char c, char color) { int a; byte x; if((c >= 0) && (c <= 5)) { a = c*5; for(int i = 0; i < 5; i++) { x = pgm_read_byte(&(symbol+a)[i]); x = ~x; x &= 0x1F; x |= color; PORTD = x; delayMicroseconds(100000/RPM); // for LED pixel width PORTD = 0b00011111, // blank delayMicroseconds(600000/RPM); // for gap between the columns } delayMicroseconds(900000/RPM); // for gap between the characters } } //------------------------------------------ void displayMultiColorStr(String str) { byte y = 1; int i = 0; char c = 1; while(c != 0) { c = str.charAt(i); displayChar(c,y<<5); i++; if(c != ' ') { y++; if(y == 8) y = 1; } } } //------------------------------------------ void space() { for(int i = 0; i < 5; i++) { PORTD = 0b00011111, // blank delayMicroseconds(100000/RPM); PORTD = 0b00011111, // blank delayMicroseconds(600000/RPM); } } //------------------------------------------