2012年10月3日 星期三

4模式的廣告燈

Sample TestSubroutine  https://www.dropbox.com/sh/v5ubv00b6vdl3hg/GHNAlyAoGj


#define SW0 2
#define SW1 3
#define LED0 4
#define LED1 5
#define LED2 6
#define LED3 7
#define LED4 8
#define LED5 9
#define LED6 10
#define LED7 11
void setup() {
  Serial.begin(9600);
  Serial.println("Chang Yung Fu <<<2012/10/4>>>");
  Serial.println("4 Mode Led Flash using  Arduino");
  pinMode(SW0,INPUT);  pinMode(SW1,INPUT);
  for (int i=0;i<=7;i++) pinMode(4+i,OUTPUT);
 }
void loop() {
  int Mode;
  char OutData;
  //4模式的表格宣告
  char Mode1[]={1,2,4,8,16,32,64,128};
  char Mode2[]={0x81,0x42,0x24,0x18,0x24,0x42};
  char Mode3[]={0xF0,0x0F};
  //Input Map to Var
  Mode=digitalRead(SW0) | (digitalRead(SW1)<<1);
  Serial.print("MODE=");Serial.println(Mode);
  switch (Mode)
     {case 0:.....;break;
       case 1:.....;break;
      case 2:......;break;
      case 3:......;break;  
     }

  //Var Map to Output
  delay(100);
}
int SN7490(boolean UP_DN,int MAX)
{
  int static i=0;
  if (UP_DN) {
    i++;
    if (i>MAX) i=0;
  }
  else {
    i--;
      if (i<0) i=MAX;
  }
  return i;
}