#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSans12pt7b.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#if (SSD1306_LCDHEIGHT != 32)
#endif

const unsigned char PROGMEM ppwwmm [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x3f, 0xff, 0x00, 0x1f, 0xff, 0x00, 0x1f, 0xff, 0x3f, 0xff, 0x00, 0x3f, 0xff, 0x00, 0x3f, 0xff, 
  0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 
  0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 
  0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 
  0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 
  0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 0x30, 0x03, 0x00, 0x30, 0x03, 0x00, 0x30, 0x00, 
  0xf0, 0x03, 0xff, 0xf0, 0x03, 0xff, 0xf0, 0x00, 0xf0, 0x03, 0xff, 0xf0, 0x03, 0xff, 0xf0, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM voltImg [] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfe, 
  0x20, 0x00, 0x00, 0x01, 0x27, 0xff, 0xff, 0xf9, 0x24, 0x00, 0x00, 0x09, 0x24, 0x00, 0x01, 0x09, 
  0x24, 0x07, 0xfa, 0x09, 0x24, 0x38, 0x07, 0x09, 0x24, 0xc0, 0x04, 0xc9, 0x25, 0x80, 0x04, 0x29, 
  0x24, 0x00, 0x08, 0x09, 0x24, 0x00, 0x08, 0x09, 0x24, 0x00, 0x10, 0x09, 0x24, 0x00, 0x30, 0x09, 
  0x24, 0x01, 0xe0, 0x09, 0x24, 0x02, 0x10, 0x09, 0x24, 0x06, 0x18, 0x09, 0x27, 0xff, 0xff, 0xf9, 
  0x20, 0x00, 0x00, 0x01, 0x21, 0x80, 0xc0, 0xe1, 0x22, 0x61, 0xa1, 0x31, 0x24, 0x23, 0x93, 0x31, 
  0x25, 0xa2, 0x92, 0x71, 0x23, 0x63, 0xb1, 0x51, 0x23, 0xc1, 0xe0, 0xe1, 0x20, 0x00, 0x00, 0x01, 
  0x18, 0x00, 0x00, 0x06, 0x0f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM baterja [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xce, 0x00, 0x00, 0x03, 0xfb, 0x80, 0x00, 0x06, 0x18, 0xc0, 
  0x00, 0x06, 0x2c, 0x60, 0x00, 0x0e, 0x26, 0x20, 0x00, 0x19, 0x33, 0xe0, 0x00, 0x11, 0x98, 0xf0, 
  0x00, 0x30, 0xce, 0x98, 0x00, 0x30, 0x63, 0x08, 0x00, 0x70, 0x18, 0x08, 0x00, 0xc8, 0x2f, 0x18, 
  0x00, 0x8c, 0x61, 0xf0, 0x01, 0x86, 0x70, 0x30, 0x03, 0x03, 0x80, 0x20, 0x02, 0x00, 0xc0, 0x40, 
  0x06, 0x00, 0x3c, 0xc0, 0x04, 0x00, 0x0f, 0x80, 0x0c, 0x00, 0x01, 0x80, 0x18, 0x00, 0x01, 0x00, 
  0x10, 0x00, 0x02, 0x00, 0x30, 0x00, 0x06, 0x00, 0x20, 0x00, 0x04, 0x00, 0x30, 0x00, 0x0c, 0x00, 
  0x10, 0x00, 0x18, 0x00, 0x18, 0x60, 0x10, 0x00, 0x0c, 0xc0, 0x30, 0x00, 0x07, 0x00, 0x20, 0x00, 
  0x01, 0x80, 0x40, 0x00, 0x00, 0xe0, 0xc0, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x07, 0x00, 0x00, 
};
const unsigned char PROGMEM continu [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0xc0, 
  0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x11, 0xe0, 0x00, 0x00, 0x30, 0xf0, 0x00, 0x00, 0x78, 0xf0, 
  0x00, 0x02, 0x3c, 0x70, 0x00, 0x0e, 0x3c, 0x78, 0x00, 0x0f, 0x1c, 0x78, 0x00, 0x47, 0x1e, 0x38, 
  0x01, 0xe7, 0x9e, 0x38, 0x01, 0xe3, 0x8e, 0x38, 0x00, 0xe3, 0x8e, 0x38, 0x30, 0xf3, 0x8e, 0x3c, 
  0x78, 0xf3, 0x8e, 0x3c, 0x78, 0xf3, 0x8e, 0x3c, 0x00, 0xf3, 0x8e, 0x3c, 0x00, 0xe3, 0x8e, 0x3c, 
  0x00, 0xe3, 0x8e, 0x38, 0x00, 0x47, 0x8e, 0x38, 0x00, 0x07, 0x9e, 0x38, 0x00, 0x03, 0x1c, 0x78, 
  0x00, 0x00, 0x3c, 0x78, 0x00, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xe0, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM resis [] = {
0x80, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x10, 0x30, 0x00, 0x00, 
  0x08, 0x78, 0x00, 0x00, 0x04, 0x8c, 0x00, 0x00, 0x03, 0x06, 0x00, 0x00, 0x02, 0x0b, 0x00, 0x00, 
  0x04, 0x11, 0x00, 0x00, 0x0c, 0x23, 0x00, 0x00, 0x18, 0x47, 0x80, 0x00, 0x18, 0x8c, 0xc0, 0x00, 
  0x0d, 0x18, 0xe0, 0x00, 0x06, 0x31, 0xb0, 0x00, 0x03, 0x63, 0x18, 0x00, 0x01, 0xe6, 0x0c, 0x00, 
  0x00, 0x3c, 0x07, 0x80, 0x00, 0x18, 0x06, 0xc0, 0x00, 0x0c, 0x0c, 0x60, 0x00, 0x06, 0x18, 0xb0, 
  0x00, 0x03, 0x31, 0x18, 0x00, 0x01, 0xe2, 0x18, 0x00, 0x00, 0xc4, 0x30, 0x00, 0x00, 0x88, 0x20, 
  0x00, 0x00, 0xd0, 0x40, 0x00, 0x00, 0x60, 0xc0, 0x00, 0x00, 0x31, 0x20, 0x00, 0x00, 0x1e, 0x10, 
  0x00, 0x00, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01
};
const unsigned char PROGMEM multilogo [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x7f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x01, 0xe1, 0xfd, 0x80, 0x00, 0xfd, 0x80, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x03, 0xc0, 0x61, 0x80, 0x00, 0xc1, 0x80, 0x00, 0x80, 0x00, 0xcc, 0x00, 0x02, 0x00, 
 0x00, 0x7f, 0xe7, 0xc0, 0x61, 0x80, 0x00, 0xc1, 0x80, 0x01, 0x80, 0x00, 0xcc, 0x00, 0x06, 0x00, 
 0x00, 0x7f, 0xe7, 0x80, 0x61, 0xf3, 0xe0, 0xc1, 0x9e, 0x3f, 0xef, 0x3c, 0xcc, 0xf1, 0xe7, 0x80, 
 0x00, 0x7f, 0xe3, 0x80, 0x61, 0xb7, 0x61, 0xf3, 0x33, 0x61, 0x8c, 0x66, 0xf9, 0x9b, 0x66, 0x00, 
 0x00, 0x70, 0x03, 0xc0, 0x63, 0x36, 0x61, 0x83, 0x33, 0xc1, 0x8c, 0xc7, 0xb3, 0x1e, 0x36, 0x00, 
 0x00, 0x70, 0x01, 0xc0, 0x63, 0x37, 0xc1, 0x83, 0x3e, 0xc3, 0x18, 0xc7, 0x9b, 0x1e, 0x6c, 0x00, 
 0x00, 0x70, 0x01, 0xe0, 0xc3, 0x36, 0x01, 0x83, 0x30, 0xcb, 0x18, 0xcd, 0x9b, 0x36, 0x6c, 0x00, 
 0x00, 0x7f, 0xf8, 0xe0, 0xc3, 0x33, 0xc3, 0xfb, 0x1c, 0x79, 0xd8, 0x79, 0x8d, 0xe3, 0xc7, 0x00, 
 0x00, 0x7f, 0xf8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x7f, 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM dioda [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x70, 0x1c, 0x00, 
  0x00, 0xc0, 0x06, 0x00, 0x01, 0x80, 0x03, 0x00, 0x01, 0x00, 0x01, 0x80, 0x03, 0x00, 0x01, 0x80, 
  0x02, 0x00, 0x00, 0xc0, 0x06, 0x00, 0x00, 0xc0, 0x06, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00, 0x40, 
  0x06, 0x04, 0x20, 0x40, 0x06, 0x0e, 0xf0, 0x40, 0x06, 0x13, 0x98, 0x40, 0x06, 0x31, 0x18, 0x40, 
  0x06, 0x30, 0x18, 0x60, 0x0c, 0x30, 0x18, 0x60, 0x0c, 0x30, 0x18, 0x60, 0x0c, 0x30, 0x18, 0x20, 
  0x0c, 0x30, 0x18, 0x60, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3c, 0x00, 
  0x00, 0x78, 0x1c, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x30, 0x18, 0x00, 
  0x00, 0x30, 0x18, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00, 0x30, 0x18, 0x00
};
int pauza=300;
int raw= 0;
float Vin= 0;
float Vout= 0;
float R1= 1800;
float R2= 0;
float vout2 = 0.00;
float vin2 = 0.00;
float res1 = 100000.00;
float res2 = 10000.00;
int val = 0;
float buffer= 0;

void setup()   {  
pinMode(5,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(13,OUTPUT);
attachInterrupt(1, pritisnuto, FALLING);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setFont(&FreeSans9pt7b);
display.drawBitmap(0,0,  multilogo, 128, 32, 1);
display.setCursor(0,56);
display.setFont();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.display();
delay(5000);
display.clearDisplay();
display.display();}
int maksimum=1;
int minimum=1024;
int stisnuto=0;
unsigned long brojPuta=0;
unsigned long zbroj=0;
int prosjek=0;
int pulse=125;
unsigned long m=0;


void loop()

{if(stisnuto==0)
{float volt3=readVcc()/10000.0;
val = analogRead(3);
vout2 = (val * volt3) / 100.0;
vin2 = vout2 / (res2/(res1+res2)); 
display.clearDisplay(); 
display.setFont();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print("VOLTMETER:MAX50V");
display.drawBitmap(96, 0,  voltImg, 32, 32, 1);
display.setCursor(70,0);
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
display.print(vin2);
display.display();
delay(500);

}if(stisnuto==1)
{if(digitalRead(4)==0)
{delay(100); minimum=1024; maksimum=0; brojPuta=0; zbroj=0; }
display.clearDisplay();
display.setFont();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.setTextSize(1);
display.print("ANALOG");
display.setCursor(95,0);
int vrije=analogRead(A0);
brojPuta=brojPuta+1;
zbroj=zbroj+vrije;
prosjek=zbroj/brojPuta;
if(vrije>maksimum)
maksimum=vrije;
if(vrije<minimum)
minimum=vrije;
int snaga=map(vrije,0,1024,0,128);
float voltaza=readVcc();
display.print(prosjek);
display.setCursor(70,0);
display.print("AVE:");
display.setCursor(70,10);
display.print("MAX:");
display.setCursor(70,20);
display.print("MIN:");
display.setCursor(95,10);
display.print(maksimum);
display.setCursor(95,20);
display.print(minimum);
display.setFont(&FreeSans9pt7b);
display.setCursor(0,24);
display.print(vrije);
display.drawLine(0,31,snaga,31,1);
display.display();
if(brojPuta>100000)
{brojPuta=0;
zbroj=0;}

}if(stisnuto==2)
{display.clearDisplay(); 
display.setFont();
display.setCursor(0,0);
display.print("RESISTANCE:Ohms");
display.drawBitmap(96, 0,  resis, 32, 32, 1);
raw= analogRead(A2);
Vin=readVcc()/1000.0;
buffer= raw * Vin;
Vout= (buffer)/1023.0;
buffer= (Vin/Vout)-1;
R2= R1 * buffer;
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
if(R2<10000000)
display.print(R2);
if(R2>10000000)
display.print("empty");
display.display();
delay(pauza);

}if(stisnuto==3)
{display.clearDisplay();
display.drawBitmap(96, 0,  dioda, 32, 32, 1);
display.setFont();
display.setCursor(0,0);
display.print("VOLTAGE DROP:");
raw= analogRead(A2);
Vin=readVcc()/1000.0;
buffer= raw * Vin;
Vout= (buffer)/1024.0;
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
if(Vout==0)
{display.print("0");}else{
display.print(Vin-Vout);}
display.display();
delay(pauza);

}if(stisnuto==4)
{display.clearDisplay();
display.drawBitmap(96, 0,  continu, 32, 32, 1);
display.setFont();
display.setCursor(0,0);
display.print("CONTINUITY:");
display.print(Vout);
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
raw= analogRead(A2);
Vin=readVcc()/1000.0;
buffer= raw * Vin;
Vout= (buffer)/1024.0;
float rez=Vin-Vout;
if(rez<1)
{tone(6,2250);
display.print("Yes");
digitalWrite(13,1);
}if(rez>1)
{noTone(6);
digitalWrite(13,0);
display.print("No");
}display.display();

}if(stisnuto==5)
{display.clearDisplay();
display.drawBitmap(96, 0,  baterja, 32, 32, 1);
display.setFont();
display.setCursor(0,0);
display.print("BATERRY:");
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
float volt2=readVcc()/1000.0;
display.print(volt2);
display.setCursor(55,28);
display.print("V");
display.display();
delay(pauza);

}if(stisnuto==6)
{if(digitalRead(4)==0)
{ if(pulse<255)
{tone(6,1800,10);
pulse=pulse+2; } 
}if(digitalRead(5)==0)
{ if(pulse>1)
{tone(6,1400,10);
pulse=pulse-2; } 
}int snaga2=0;
analogWrite(9,pulse);
display.clearDisplay();
display.drawBitmap(72, 1,  ppwwmm, 58, 30, 1);
display.setFont();
display.setCursor(0,0);
display.print("PULSE WIDTH:");
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
display.print(pulse);
snaga2= map(pulse,0,255,0,128);
display.drawLine(0,31,snaga2,31,1);
display.display();}  

if(stisnuto==7)
{display.clearDisplay();
display.drawBitmap(0,0,  multilogo, 128, 32, 1);
display.setFont();
display.setCursor(0,0);
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
display.display();
delay(pauza);}  


}void pritisnuto()
{static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
if (interrupt_time - last_interrupt_time > 220) {
stisnuto++;
tone(6,2250,50);
if(stisnuto>7)
stisnuto=0;}
last_interrupt_time = interrupt_time;}
long readVcc() {
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif  
delay(2);
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA,ADSC));
uint8_t low  = ADCL;
uint8_t high = ADCH;
long result = (high<<8) | low;
result = 1125300L / result;
return result;
}