Механический дисплей (по мотивам статьи на Хабре)

Тема в разделе "Глядите, что я сделал", создана пользователем darkavenger, 18 авг 2013.

  1. darkavenger

    darkavenger Гик

    Механический дисплей из LEGO Technic и TI MSP430 LaunchPad
    По мотивам цикла статей commanderxo на Хабре, используем msp430 Launchpad вместо Arduino, выводим бегущую строку в воздухе.



    Код (Text):

      int del = 4000;  // pixel "length" in microseconds

    void setup()
    {
      for (int i = 3; i <= 10; i++)
      {
        pinMode(i, OUTPUT);
      }
    }

    // Bit map of the picture (right to left) that we are going to show
    unsigned char Word[] = {
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B01101110,
      B10010001,
      B10010001,
      B11111111,
      B00000000,
      B01111110,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B11110000,
      B10010000,
      B10010000,
      B11111111,
      B00000000,
      B10000001,
      B10010001,
      B10010001,
      B11111111,
      B00000000,
      B11111111,
      B10000000,
      B11111110,
      B00000001,
      B00000000,
      B11111111,
      B10000000,
      B11111110,
      B00000001,
      B00000000,
      B01111110,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B11110000,
      B10010000,
      B10010000,
      B11111111,
      B00000000,
      B10000000,
      B10000000,
      B11111111,
      B10000000,
      B10000000,
      B00000000,
      B11111111,
      B00010000,
      B00010000,
      B11111111,
      B00000000,
      B01111110,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B11000011,
      B00100100,
      B00011000,
      B11111111,
      B00000000,
      B01111110,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B11110000,
      B10010000,
      B10010000,
      B11111111,
      B00000000,
      B11000011,
      B00100100,
      B00011000,
      B11111111,
      B00000000,
      B11111111,
      B00100000,
      B00010000,
      B11111111,
      B00000000,
      B11111111,
      B01000000,
      B00100000,
      B01000000,
      B11111111,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B01101110,
      B10010001,
      B10010001,
      B01000010,
      B00000000,
      B11111111,
      B00100000,
      B00010000,
      B11111111,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B11111111,
      B01000000,
      B00100000,
      B01000000,
      B11111111,
      B00000000,
      B11111111,
      B00100000,
      B00010000,
      B11111111,
      B00000000,
      B01111110,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B11110000,
      B10010000,
      B10010000,
      B11111111,
      B00000000,
      B10000000,
      B10000000,
      B11111111,
      B10000000,
      B10000000,
      B00000000,
      B01000010,
      B10000001,
      B10000001,
      B01111110,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000,
      B00000000};










    void loop()
    {
      for(int w = 181; w > 0; w--)
      {
     
      // Wait for the synchronization (photoresistor covered by the motor bar)
      waitForBegin();
     
      // Do not start from the imidiatelly as the LED beam is moving too slow in the first milliseconds
      delay(20);


     
          for(int i = 0; i < 26; i++)
          {
          showByte(Word[i+w], del);
          }

       
      }  
    }

    void waitForBegin()
    {
      while (analogRead(A0) > 24)
      {
        delayMicroseconds(200);
      }
    }  

    void showByte(int info, long del)
    {
      // Light LEDs if necessary
      for (int i = 3; i <= 10; i++)
      {
        digitalWrite(i, (info & 0x01) ? HIGH : LOW);         
        info >>= 1;
      }
     
      // Wait a little
      if (del < 30000)
      {
        delayMicroseconds(del);
      }
      else
      {  
        delay (del/1000);
      }
     
      // Turn LEDs off
      for (int i = 3; i <= 10; i++)
      {
        digitalWrite(i, LOW);        
      }
    }


     
     
    Борис нравится это.
  2. Корней

    Корней Гик

    Привет с ВС! ;)