byte hart[] = { B01010, B10101, B10001, B01010, B00100}; byte dw[] = { B00000, B00000, B11111, B00000, B00000}; byte op[] = { B00100, B00100, B00100, B00100, B00100}; byte fs[] = { B00001, B00010, B00100, B01000, B10000}; byte bs[] = { B10000, B01000, B00100, B00010, B00001}; byte A[] = { B00100, B01010, B11111, B10001, B10001}; byte B[] = { B11110, B10001, B11110, B10001, B11110}; byte C[] = { B11111, B10000, B10000, B10000, B11111}; byte D[] = { B11110, B10001, B10001, B10001, B11110}; byte E[] = { B11111, B10000, B11110, B10000, B11111}; byte F[] = { B11111, B10000, B11100, B10000, B10000}; byte G[] = { B11111, B10000, B10011, B10001, B01110}; byte H[] = { B10001, B10001, B11111, B10001, B10001}; byte I[] = { B01110, B00100, B00100, B00100, B01110}; byte J[] = { B11111, B00001, B00001, B10001, B01110}; byte K[] = { B10001, B10010, B10100, B11010, B10001}; byte L[] = { B10000, B10000, B10000, B10000, B11110}; byte M[] = { B01010, B10101, B10101, B10001, B10001}; byte N[] = { B10001, B11001, B10101, B10011, B10001}; byte O[] = { B01110, B10001, B10001, B10001, B01110}; byte P[] = { B11110, B10001, B11110, B10000, B10000}; byte Q[] = { B01110, B10001, B10101, B01110, B00100}; byte R[] = { B11110, B10001, B11110, B10001, B10001}; byte S[] = { B01111, B10000, B01110, B00001, B11110}; byte T[] = { B11111, B00100, B00100, B00100, B00100}; byte U[] = { B10001, B10001, B10001, B10001, B01110}; byte V[] = { B10001, B10001, B10001, B01010, B00100}; byte W[] = { B10001, B10001, B10101, B10101, B01010}; byte X[] = { B10001, B01010, B00100, B01010, B10001}; byte Y[] = { B10001, B01010, B00100, B00100, B00100}; byte Z[] = { B11111, B00010, B00100, B01000, B11111}; byte n1[] = { B00100, B01100, B10100, B00100, B11111}; byte n2[] = { B01100, B10010, B00100, B01000, B11111}; byte n3[] = { B01110, B10001, B00110, B10001, B01110}; byte n4[] = { B00110, B01010, B11111, B00010, B00010}; byte n5[] = { B11111, B10000, B11110, B00001, B11110}; byte n6[] = { B01110, B10000, B11110, B10001, B01110}; byte n7[] = { B11111, B00010, B00100, B01000, B10000}; byte n8[] = { B01110, B10001, B01110, B10001, B01110}; byte n9[] = { B00111, B01001, B00111, B00001, B00001}; byte n0[] = { B01110, B11001, B10101, B10011, B01110}; byte smily[] = { B01010, B00000, B10001, B10001, B01110}; byte P1[] = { B10101, B10101, B10101, B00000, B10101}; byte P2[] = { B00000, B00100, B00000, B00100, B00000}; byte P3[] = { B00000, B00100, B00000, B00100, B00000}; byte ZAP[] ={ B00100, B00100, B11110, B11111, B11111}; byte GLIDER1[] ={ B00000, B00100, B00010, B01110, B00000}; byte GLIDER2[] ={ B00000, B01010, B00110, B00100, B00000}; byte GLIDER3[] ={ B00000, B00010, B01010, B00110, B00000}; byte GLIDER4[] ={ B00000, B00110, B00111, B01100, B00000}; //=== pin assignment === int sw = 4; int adj1 = 5; int adj2 = 6; int rcwl = 2; const int columnPins[] = {13,A3,A2,A1,A0}; const int rowPins[] = {8,9,10,11,12}; const int SERVO_PIN = 3; int incomingByte; int dist; //for storing VL53LOX value int prox; //for storing RCWL value #include #include #include VL53L0X sensor; #define LONG_RANGE //#define HIGH_SPEED #define HIGH_ACCURACY Servo servo; void setup() { Serial.begin(9600); //=== VL53LOX == Wire.begin(); sensor.init(); sensor.setTimeout(500); #if defined LONG_RANGE // lower the return signal rate limit (default is 0.25 MCPS) sensor.setSignalRateLimit(0.1); // increase laser pulse periods (defaults are 14 and 10 PCLKs) sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18); sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14); #endif #if defined HIGH_SPEED // reduce timing budget to 20 ms (default is about 33 ms) sensor.setMeasurementTimingBudget(20000); #elif defined HIGH_ACCURACY // increase timing budget to 200 ms sensor.setMeasurementTimingBudget(200000); #endif //=== RCWL sensor === pinMode(rcwl, INPUT); //=== power LED FET switch === pinMode(sw, OUTPUT); digitalWrite(sw, LOW); pinMode(adj1, OUTPUT); pinMode(adj2, OUTPUT); analogWrite(adj1, 100); //dimm LED to approx 50% analogWrite(adj2, 100); //dimm LED to approx 50% //=== LED matrix === for (int i = 0; i < 5; i++){ pinMode(rowPins[i], OUTPUT); // make all the LED pins outputs pinMode(columnPins[i], OUTPUT); digitalWrite(columnPins[i], HIGH); // disconnect column pins from Ground digitalWrite(rowPins[i], LOW); // disconnect column pins from Ground } // servo.attach(SERVO_PIN); } void loop() { // servo.write(90); // delay(3000); // servo.write(180); // see if there's incoming serial data: if (Serial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); Serial.print("==="); // if it's an L (ASCII 76) turn off the LED: if (incomingByte == 'A') { show(A, 500); } if (incomingByte == 'B') { show(B, 500); } if (incomingByte == 'C') { show(C, 500); } if (incomingByte == 'D') { show(D, 500); } if (incomingByte == 'E') { show(E, 500); } if (incomingByte == 'F') { show(F, 500); } if (incomingByte == 'G') { show(G, 500); } if (incomingByte == 'H') { show(H, 500); } if (incomingByte == 'I') { show(I, 500); } if (incomingByte == 'J') { show(J, 500); } if (incomingByte == 'K') { show(K, 500); } if (incomingByte == 'L') { show(L, 500); } if (incomingByte == 'M') { show(M, 500); } if (incomingByte == 'N') { show(N, 500); } if (incomingByte == 'O') { show(O, 500); } if (incomingByte == 'P') { show(P, 500); } if (incomingByte == 'Q') { show(Q, 500); } if (incomingByte == 'R') { show(R, 500); } if (incomingByte == 'S') { show(S, 500); } if (incomingByte == 'T') { show(T, 500); } if (incomingByte == 'U') { show(U, 500); } if (incomingByte == 'V') { show(V, 500); } if (incomingByte == 'W') { show(W, 500); } if (incomingByte == 'X') { show(X, 500); } if (incomingByte == 'Y') { show(Y, 500); } if (incomingByte == 'Z') { show(Z, 500); } if (incomingByte == '0') { show(n0, 500); } if (incomingByte == '1') { show(n1, 500); } if (incomingByte == '2') { show(n2, 500); } if (incomingByte == '3') { show(n3, 500); } if (incomingByte == '4') { show(n4, 500); } if (incomingByte == '5') { show(n5, 500); } if (incomingByte == '6') { show(n6, 500); } if (incomingByte == '7') { show(n7, 500); } if (incomingByte == '8') { show(n8, 500); } if (incomingByte == '9') { show(n9, 500); } if (incomingByte == ' ') { delay(400); } if (incomingByte == '!') { show(P1, 500); } if (incomingByte == 'ZAP') { show(ZAP, 500); } if (incomingByte == 'SMILY') { show(smily, 500); } if (incomingByte == '-') { show(dw, 500); } if (incomingByte == '|') { show(op, 500); } if (incomingByte == '/') { show(fs, 500); } if (incomingByte == '<') { show(bs, 500); } if (incomingByte == 'HART') { show(hart, 500); } if (incomingByte == ':') { show(P2, 500); } if (incomingByte == ';') { show(P3, 500); } if (incomingByte == 'a') { show(O, 500);show(W, 500); delay(400); show(Y, 500);show(E, 500);show(S, 500); } } dist = sensor.readRangeSingleMillimeters(); prox = digitalRead(rcwl); Serial.print(dist); Serial.print("/"); Serial.println(prox, DEC); //===TEST SEQUENCE=== if(dist <1560 & prox == 1){ for(int i=0;i<3; i++){ show(GLIDER1, 1000); show(GLIDER2, 1000); show(GLIDER3, 1000); show(GLIDER4, 1000); } delay(3000); analogWrite(adj1, 255); analogWrite(adj2, 255); digitalWrite(sw, HIGH); //trun on LEDs for(int val=255;val>30;val--){ analogWrite(adj1, val); analogWrite(adj2, val); Serial.println(val); delay(15); } delay(5000); for(int val=30;val<255;val++){ analogWrite(adj1, val); analogWrite(adj2, val); Serial.println(val); delay(30); } } digitalWrite(sw, LOW); //trun off LEDs } // Function to drive 5x5 LED matrix void show( byte * image, unsigned long duration) { unsigned long start = millis(); // begin timing the animation while (start + duration > millis()) // loop until the duration period has passed { for(int row = 0; row < 5; row++){ digitalWrite(rowPins[row], HIGH); // connect row to +5 volts //Serial.println(); for(int column = 0; column < 5; column++){ boolean pixel = bitRead(image[row],column); if(pixel == 1) { digitalWrite(columnPins[column], LOW); // connect column to Gnd } delayMicroseconds(30); // a small delay for each LED digitalWrite(columnPins[column], HIGH); // disconnect column from Gnd //Serial.print(bitRead(image[row],column)); } digitalWrite(rowPins[row], LOW); // disconnect LEDs } } }