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


Ignore:
Timestamp:
Feb 12, 2010, 12:11:10 AM (14 years ago)
Author:
wade
Comment:

--

Legend:

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

    v1 v1  
     1{{{
     2/*                           
     3 *              08 07 06 05 04 03 02 01
     4 *                                   *
     5 * 74HC595  PIN 09 10 11 12 13 14 15 16
     6 *                    SH ST    DS
     7 *                    棕 白    紫
     8 * Arduino  PIN       3  2     4
     9 *     
     10 */
     11
     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};
     15byte data_0[8]={0x03E, 0x051, 0x049, 0x045, 0x03E, 0x0FF, 0x0FF, 0x0FF};
     16// ascii 5x7 dot font
     17byte data_ascii[][8] = {
     18                       data_ascii_Z
     19                       }; // 9
     20
     21//Pin connected to ST_CP of 74HC595 for scanning
     22int scan_latch_pin = 5;
     23//Pin connected to SH_CP of 74HC595 for scanning
     24int scan_clock_pin = 6;
     25//Pin connected to DS of 74HC595 for scanning
     26int 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;
     33
     34
     35void setup() {
     36  //set pins to output because they are addressed in the main loop
     37  pinMode(scan_latch_pin, OUTPUT);
     38  pinMode(scan_clock_pin, OUTPUT);
     39  pinMode(scan_data_pin, OUTPUT);
     40  Serial.begin(9600);
     41  for (int i = 0; i< 8; i++)
     42    data_ascii[0][i] ^= 0xFF;
     43 
     44}
     45
     46void loop() {
     47  //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);
     58  }
     59}
     60
     61void scan_line()
     62{
     63  //count up routine
     64  for (int j = 1; j <= 256; j <<= 1)
     65  {
     66    //ground scan_latch_pin and hold low for as long as you are transmitting
     67    digitalWrite(scan_latch_pin, LOW);
     68    shiftOut(scan_data_pin, scan_clock_pin, MSBFIRST, j);   
     69    //return the latch pin high to signal chip that it
     70    //no longer needs to listen for information
     71    digitalWrite(scan_latch_pin, HIGH);
     72    delay(500);
     73  }
     74}
     75
     76}}}