#include <TM1637.h>
const int CLK = 2;
const int DIO = 3;
const int BUZ = 4;
const int potPin = A0;
TM1637 tm(CLK, DIO);
void wakeUp() {
tone(BUZ, 400);
delay(200);
noTone(BUZ);
tone(BUZ, 600);
delay(200);
noTone(BUZ);
}
void amperDisp() {
int potValue1 = analogRead(potPin);
potValue1 = 0;
for (int i = 0; i < 10; i++) {
potValue1 = potValue1 + analogRead(potPin);
delay(5);
}
potValue1 = potValue1 / 10;
potValue1 = map(potValue1, 0, 1023, 1, 26);
int potValue = map(potValue1, 1, 26, 10, 130);
// tm.displayInt(potValue);
tm.display(0, (potValue / 1000) % 10);
tm.display(1, (potValue / 100) % 10);
tm.display(2, (potValue / 10) % 10);
tm.display(3, potValue % 10);
}
void alarm() {
}
void setup() {
tm.init();
tm.set(BRIGHT_TYPICAL);
Serial.begin(9600);
wakeUp();
byte digs[4] = {0, 0, 0, 0};
// tm.twist(digs, 40); // скорость прокрутки 100
delay(500);
}
unsigned int counter = 0;
void loop() {
amperDisp();
delay(100);
}