Display/Relógio Drogaderma

De Garoa Hacker Clube
Ir para: navegação, pesquisa

http://www.lxdinc.com/faq/direct_drive_multiplexing

int a=2,b=3,c=4,d=5;
int PIN28=6;
int PIN29=7;

void setup(){
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(PIN28, OUTPUT);
  pinMode(PIN29, OUTPUT);
}

int line=0;
int counter=0;
void loop(){
  line=(line+1)%2;

  digitalWrite(PIN28, line==0 ? HIGH : LOW);
  digitalWrite(PIN29, line==1 ? HIGH : LOW);

  switch(line){
    case 0:
      digitalWrite(a, LOW);
      digitalWrite(b, HIGH);//c
      digitalWrite(c, LOW);
      digitalWrite(d, LOW);
      break;
    case 1:
      digitalWrite(a, LOW);
      digitalWrite(b, HIGH);
      digitalWrite(c, HIGH); //f
      digitalWrite(d, HIGH); //SAT
      break;
    default:
      break;
  }
  
  delay(10);
}