EXP_IO.C  



Example to expand number of I/O using 74165 & 74595

/////////////////////////////////////////////////////////////////////////
////                         EX_EXPIO.C                               ////
////                                                                  ////
////     This program shows how to use the 74165.C and 74595.C        ////
////  libraries for extended input and output.                        ////
////                                                                  ////
////     When button S1 is pushed, LED 1 will toggle green.  Button   ////
////  S2 will toggle LED 2.  However, when both buttons are pushed,   ////
////  LED 3 will toggle green.                                        ////
////                                                                  ////
////        (C) Copyright 1996,1997 Custom Computer Services          ////
////                                                                  ////
//////////////////////////////////////////////////////////////////////////

#ifdef __PCB__
#include <16C56.H>
#else
#include <16C74.H>
#endif

#include <74595.C>
#include <74165.C>

main() {
   byte data;

   do {
      read_expanded_inputs (&data);
      
      data |= 0xF8;                           //Force the unused input bits on
      data -= (!(data&0x01)&!(data&0x02))<<2; //Turn on bit 2 it both inputs are
                                              //toggled
      write_expanded_outputs (&data);
   } while (TRUE);
}



Navigation Bar

tech_support@blitzlogic.com