/* Joginder hobbyprojects 05-09-2020 Vibration_based_LED_POV_Message_Display.ino */ #define Delay 250 int sensor_pin = 8; int input_state; int val; int LED = 13; unsigned long n = 0; void setup() { DDRD = 0xFF; pinMode(sensor_pin, INPUT_PULLUP); pinMode(LED,OUTPUT); TIMSK2 = (TIMSK2 & B11111110) | 0x01; TCCR2B = (TCCR2B & B11111000) | 0x02; } void loop() { input_state = digitalRead(sensor_pin); while (input_state == HIGH) { input_state = digitalRead(sensor_pin); } delay2(); //delay2(); //delay2(); // display "Happy New Year" // letter 'H' PORTD = 0x7f; // column data delay1(); // LED pixel width PORTD = 0x00; // All LEDs OFF delay1(); // gap between columns PORTD = 0x08; // column data delay1(); // LED pixel width PORTD = 0x00; // All LEDs OFF delay1(); // gap between columns PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x7f; delay1(); PORTD = 0x00; delay1(); delay2(); // gap between letters // letter 'a' PORTD = 0x02; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x0f; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'p' PORTD = 0x1f; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'p' PORTD = 0x1f; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x14; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'y' PORTD = 0x18; delay1(); PORTD = 0x00; delay1(); PORTD = 0x05; delay1(); PORTD = 0x00; delay1(); PORTD = 0x05; delay1(); PORTD = 0x00; delay1(); PORTD = 0x05; delay1(); PORTD = 0x00; delay1(); PORTD = 0x1e; delay1(); PORTD = 0x00; delay1(); delay2(); delay2(); // letter 'N' PORTD = 0x7f; delay1(); PORTD = 0x00; delay1(); PORTD = 0x10; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x04; delay1(); PORTD = 0x00; delay1(); PORTD = 0x7f; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'e' PORTD = 0x0e; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x0c; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'w' PORTD = 0x1e; delay1(); PORTD = 0x00; delay1(); PORTD = 0x01; delay1(); PORTD = 0x00; delay1(); PORTD = 0x06; delay1(); PORTD = 0x00; delay1(); PORTD = 0x01; delay1(); PORTD = 0x00; delay1(); PORTD = 0x1e; delay1(); PORTD = 0x00; delay1(); delay2(); delay2(); // letter 'Y' PORTD = 0x70; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x07; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x70; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'e' PORTD = 0x0e; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x0c; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'a' PORTD = 0x02; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x15; delay1(); PORTD = 0x00; delay1(); PORTD = 0x0f; delay1(); PORTD = 0x00; delay1(); delay2(); // letter 'r' PORTD = 0x1f; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); PORTD = 0x10; delay1(); PORTD = 0x00; delay1(); PORTD = 0x10; delay1(); PORTD = 0x00; delay1(); PORTD = 0x08; delay1(); PORTD = 0x00; delay1(); input_state = digitalRead(sensor_pin); while (input_state == LOW) { val = analogRead(A0); if(val < 50) val = 50; input_state = digitalRead(sensor_pin); } } void delay1() { delayMicroseconds(Delay); } void delay2() { delayMicroseconds(Delay*3); } ISR(TIMER2_OVF_vect) { n++; if(n >= val) { n = 0; digitalWrite(LED, !digitalRead(LED)); } }