uint8_t led[4]={19,21,22,35};
uint8_t tombol[4]={2,4,16,5};
uint8_t sseg[3]={17,5,18};
uint8_t buzzer=15;
uint8_t lm35=13;
//f e d c b a h g
uint8_t dseg[10][8]={{0,0,0,0,0,0,1,1}, //0
{1,1,1,0,0,1,1,1}, //1
{1,0,0,1,0,0,1,0}, //2
{1,1,0,0,0,0,1,1}, //3
{0,1,1,0,0,1,1,0}, //4
{0,1,0,0,1,0,1,0}, //5
{0,0,0,0,1,0,1,0}, //6
{1,1,1,0,0,0,1,1}, //7
{0,0,0,0,0,0,1,0}, //8
{0,1,0,0,0,0,1,0}}; //9
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
for(uint8_t i=0;i<4;i++){
pinMode(tombol[i],INPUT_PULLUP);
pinMode(led[i],OUTPUT);
}
pinMode(sseg[0],OUTPUT);
pinMode(sseg[1],OUTPUT);
pinMode(sseg[2],OUTPUT);
pinMode(buzzer,OUTPUT);
for(uint8_t i=0;i<4;i++)
digitalWrite(led[i], HIGH);
}
uint8_t hitung=0;
void loop() {
uint8_t potensio=analogRead(lm35) * (9.0 / 4095.0);
// put your main code here, to run repeatedly:
for(uint8_t i=0;i<8;i++)
digitalWrite(led[i],digitalRead(tombol[i]));
for(uint8_t i=0;i<8;i++){
digitalWrite(sseg[1],HIGH);
digitalWrite(sseg[2],HIGH);
digitalWrite(sseg[0],HIGH);
digitalWrite(sseg[2],LOW);
digitalWrite(sseg[1],LOW);
}
for(uint8_t i=0;i<8;i++){
digitalWrite(sseg[1],HIGH);
digitalWrite(sseg[2],HIGH);
digitalWrite(sseg[0],dseg[potensio][i]);
digitalWrite(sseg[2],LOW);
digitalWrite(sseg[1],LOW);
}
delay(500);
if (hitung<9)
hitung++;
else
hitung=0;
tone(buzzer,700);
delay(potensio*10);
tone(buzzer,500);
delay(potensio*10);
tone(buzzer,700);
delay(potensio*10);
noTone(buzzer);
delay(potensio*10);
}