Changes between Version 1 and Version 2 of wade/embedded/arduino/example/example_3-3


Ignore:
Timestamp:
Feb 22, 2010, 3:39:31 PM (15 years ago)
Author:
wade
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • wade/embedded/arduino/example/example_3-3

    v1 v2  
    99 *     
    1010 */
     11// display array size
     12#define display_array_size 64
     13// ascii 5x7 dot font
     14#define data_ascii_A 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, 0x00, 0x00  // A 65
     15#define data_ascii_R 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, 0x00, 0x00  // R 82
     16#define data_ascii_D 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x00  // D 68
     17#define data_ascii_U 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x00  // U 85
     18#define data_ascii_I 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, 0x00, 0x00  // I 73
     19#define data_ascii_N 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x00, 0x00  // N 78
     20#define data_ascii_O 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x00  // O 79
     21#define data_ascii_colon 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00  // : 58
     22// byte data_0[5]={0x03E, B00111110, 0x049, 0x045, 0x03E};
     23// display array
     24byte data_ascii[][display_array_size] = {
     25                       data_ascii_A,
     26                       data_ascii_R,
     27                       data_ascii_D,
     28                       data_ascii_U,
     29                       data_ascii_I,
     30                       data_ascii_N,
     31                       data_ascii_O,
     32                       data_ascii_colon
     33                       };
    1134
    12 #define data_ascii_Y {0x03, 0x04, 0x78, 0x04, 0x03} // Y 89
    13 #define data_ascii_Z {0x61, 0x59, 0x49, 0x4D, 0x43} // Z 90
    14 //byte data_0[5]={0x03E, B00111110, 0x049, 0x045, 0x03E};
    15 byte data_0[8]={0x03E, 0x051, 0x049, 0x045, 0x03E, 0x0FF, 0x0FF, 0x0FF};
    16 // ascii 5x7 dot font
    17 byte data_ascii[][8] = {
    18                        data_ascii_Z
    19                        }; // 9
    20 
    21 //Pin connected to ST_CP of 74HC595 for scanning
     35// Pin connected to ST_CP of 74HC595 for scanning
    2236int scan_latch_pin = 5;
    23 //Pin connected to SH_CP of 74HC595 for scanning
     37// Pin connected to SH_CP of 74HC595 for scanning
    2438int scan_clock_pin = 6;
    25 //Pin connected to DS of 74HC595 for scanning
     39// Pin connected to DS of 74HC595 for scanning
    2640int scan_data_pin = 7;
    27 //Pin connected to ST_CP of 74HC595 for data
    28 //int data_latch_pin = 5;
    29 //Pin connected to SH_CP of 74HC595 for data
    30 //int data_clock_pin = 6;
    31 //Pin connected to DS of 74HC595 for data
    32 //int data_data_pin = 7;
    3341
    3442
     
    3947  pinMode(scan_data_pin, OUTPUT);
    4048  Serial.begin(9600);
    41   for (int i = 0; i< 8; i++)
    42     data_ascii[0][i] ^= 0xFF;
    43  
     49  for (int i = 0; i < display_array_size; i++)
     50    data_ascii[0][i] ^= 0xFF; 
    4451}
    4552
    4653void loop() {
     54  for (int i = 1; i < (display_array_size - 8); i++ )
     55    display_led_from(i, 100);
     56}
     57
     58void display_led_from(int index, int continue_time)
     59{
    4760  //count up routine
    48   for (int j = 0; j < 8; j++) {
    49     //ground scan_latch_pin and hold low for as long as you are transmitting
    50     digitalWrite(scan_latch_pin, LOW);
    51     shiftOut(scan_data_pin, scan_clock_pin, MSBFIRST, int(1 << j));
    52     shiftOut(scan_data_pin, scan_clock_pin, MSBFIRST, int(data_ascii[0][j] ));
    53     //return the latch pin high to signal chip that it
    54     //no longer needs to listen for information
    55     digitalWrite(scan_latch_pin, HIGH);
    56     //Serial.println(data_ascii[0][j] ^= 0xFF, HEX);
    57     delay(1);
     61  for (int k = 0; k < continue_time; k++)
     62  {
     63    for (int j = index; j < (index + 8); j++) {
     64      //ground scan_latch_pin and hold low for as long as you are transmitting
     65      digitalWrite(scan_latch_pin, LOW);
     66      shiftOut(scan_data_pin, scan_clock_pin, MSBFIRST, int(1 << (j-index)));
     67      shiftOut(scan_data_pin, scan_clock_pin, MSBFIRST, int(data_ascii[0][j] ));
     68      //return the latch pin high to signal chip that it
     69      //no longer needs to listen for information
     70      digitalWrite(scan_latch_pin, HIGH);
     71      //Serial.print(1 << j-index, HEX);
     72      //Serial.print(" = ");
     73      //Serial.println(data_ascii[0][j], HEX);
     74      //delay(1000);
     75    }
    5876  }
    5977}