/*
* programa para controlar um display de 7 segmentos
* C4
* B3 D5
* A2
* E6 G8
* F7 H9
*/
#define A2 2
#define B3 3
#define C4 4
#define D5 5
#define E6 6
#define F7 7
#define G8 8
#define H9 9
int tempo = 1000;
#define buzzer 12
void setup() {
pinMode(A2,OUTPUT);
pinMode(B3,OUTPUT);
pinMode(C4,OUTPUT);
pinMode(D5,OUTPUT);
pinMode(E6,OUTPUT);
pinMode(F7,OUTPUT);
pinMode(G8,OUTPUT);
pinMode(H9,OUTPUT);
pinMode(buzzer,OUTPUT);
}
void loop() {
tempo = tempo - 50;
for (int i = 0; i < 10; i++) {
switch (i) {
case 0:
zero();
break;
case 1:
um();
break;
case 2:
dois();
break;
case 3:
tres();
break;
case 4:
quatro();
break;
case 5:
cinco();
break;
case 6:
seis();
break;
case 7:
sete();
break;
case 8:
oito();
break;
case 9:
nove();
break;
}
//limpa();
Buzzer(2500);
delay(tempo);
}
}
void limpa(){
digitalWrite(A2, LOW);
digitalWrite(B3, LOW);
digitalWrite(C4, LOW);
digitalWrite(D5, LOW);
digitalWrite(E6, LOW);
digitalWrite(F7, LOW);
digitalWrite(G8, LOW);
digitalWrite(H9, LOW);
}
void zero(){
digitalWrite(A2, LOW);
digitalWrite(B3, HIGH);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, HIGH);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void um(){
digitalWrite(A2, LOW);
digitalWrite(B3, LOW);
digitalWrite(C4, LOW);
digitalWrite(D5, HIGH);
digitalWrite(E6, LOW);
digitalWrite(F7, LOW);
digitalWrite(G8, HIGH);
}
void dois(){
digitalWrite(A2, HIGH);
digitalWrite(B3, LOW);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, HIGH);
digitalWrite(F7, HIGH);
digitalWrite(G8, LOW);
}
void tres(){
digitalWrite(A2, HIGH);
digitalWrite(B3, LOW);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, LOW);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void quatro(){
digitalWrite(A2, HIGH);
digitalWrite(B3, HIGH);
digitalWrite(C4, LOW);
digitalWrite(D5, HIGH);
digitalWrite(E6, LOW);
digitalWrite(F7, LOW);
digitalWrite(G8, HIGH);
}
void cinco(){
digitalWrite(A2, HIGH);
digitalWrite(B3, HIGH);
digitalWrite(C4, HIGH);
digitalWrite(D5, LOW);
digitalWrite(E6, LOW);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void seis(){
digitalWrite(A2, HIGH);
digitalWrite(B3, HIGH);
digitalWrite(C4, HIGH);
digitalWrite(D5, LOW);
digitalWrite(E6, HIGH);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void sete(){
digitalWrite(A2, LOW);
digitalWrite(B3, LOW);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, LOW);
digitalWrite(F7, LOW);
digitalWrite(G8, HIGH);
}
void oito(){
digitalWrite(A2, HIGH);
digitalWrite(B3, HIGH);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, HIGH);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void nove(){
digitalWrite(A2, HIGH);
digitalWrite(B3, HIGH);
digitalWrite(C4, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(E6, LOW);
digitalWrite(F7, HIGH);
digitalWrite(G8, HIGH);
}
void ponto(){
digitalWrite(H9, HIGH);
}
void Buzzer(int Freq){
tone(buzzer,Freq,100);
}
Nenhum comentário:
Postar um comentário