Hi,
The error: 'sensors' was not declared in this scope
came when testing the code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSans12pt7b.h>
/*
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 7
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
//OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
//DallasTemperature sensors(&oneWire);
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#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,
0x03, 0xFF, 0xBE, 0x00, 0x3F, 0xE0, 0x1F, 0x00, 0x02, 0x21, 0xE3, 0x00, 0x33, 0x30, 0x31, 0x00,
0x02, 0x20, 0x73, 0x00, 0x23, 0x18, 0x33, 0x80, 0x02, 0x3C, 0x71, 0x80, 0x66, 0x98, 0x67, 0x80,
0x02, 0x3E, 0x31, 0xBE, 0x66, 0x9C, 0x45, 0x80, 0x02, 0x3E, 0x39, 0xFF, 0xC7, 0xDC, 0xE9, 0x80,
0x02, 0x3E, 0x38, 0xE1, 0xCF, 0xF7, 0x89, 0x80, 0x02, 0x30, 0x7C, 0xE1, 0xCF, 0x23, 0x91, 0x80,
0x02, 0x20, 0xEC, 0xD1, 0x8E, 0x33, 0x31, 0x80, 0x02, 0x60, 0xE4, 0x40, 0x9E, 0x33, 0x31, 0x80,
0x02, 0x3F, 0xC6, 0x4C, 0x9E, 0x39, 0x71, 0x80, 0x02, 0x3F, 0x86, 0x4C, 0xBA, 0x3F, 0xF1, 0x80,
0x02, 0x30, 0x02, 0x5E, 0xBA, 0x3F, 0xF1, 0x80, 0x02, 0x70, 0x03, 0x5E, 0xB2, 0x37, 0xF1, 0x80,
0x03, 0xB0, 0x03, 0x7E, 0xF2, 0x33, 0x91, 0x80, 0x03, 0xF0, 0x01, 0xFB, 0xF3, 0xF0, 0x1F, 0x80,
0x00, 0xE0, 0x00, 0x70, 0xC0, 0xE0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 aslovo [] = {
0xF0, 0x00, 0x9F, 0xFF, 0x90, 0x00, 0xF0, 0x00, 0x40, 0x20, 0x40, 0x60, 0x40, 0x50, 0x40, 0xD0,
0x40, 0x88, 0x40, 0x88, 0x41, 0x08, 0x41, 0x08, 0x41, 0xF8, 0x41, 0x04, 0x41, 0x04, 0x40, 0x00,
0xF0, 0x00, 0x90, 0x00, 0x9F, 0xFF, 0xF0, 0x00, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x72,
0x2F, 0x00,
};
const unsigned char PROGMEM sat1 [] = {
0x0F, 0x80, 0x01, 0xF0, 0x39, 0xC0, 0x03, 0x9C, 0x61, 0x80, 0x01, 0x86, 0x43, 0x1F, 0xF8, 0xC2,
0xC6, 0x70, 0x0E, 0x63, 0x8D, 0xC0, 0x03, 0xB1, 0x9B, 0x00, 0x00, 0xD9, 0xF6, 0x01, 0x80, 0x6F,
0xEC, 0x01, 0x80, 0x37, 0x58, 0x01, 0x80, 0x1A, 0x10, 0x01, 0x80, 0x08, 0x30, 0x01, 0x80, 0x0C,
0x20, 0x01, 0x80, 0x04, 0x20, 0x01, 0x80, 0x04, 0x20, 0x01, 0x80, 0x04, 0x60, 0x01, 0x80, 0x06,
0x60, 0x01, 0x80, 0x06, 0x60, 0x7F, 0x80, 0x06, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x06,
0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x0C, 0x10, 0x00, 0x00, 0x08,
0x18, 0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 0x10, 0x0C, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x60,
0x0F, 0x80, 0x01, 0xF0, 0x18, 0xE0, 0x07, 0x18, 0x30, 0x7C, 0x3E, 0x0C, 0x20, 0x0F, 0xF0, 0x04
};
const unsigned char PROGMEM baterja [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0xFF, 0xF0, 0x40, 0x00, 0x00, 0x10, 0x47, 0x3C, 0xE0, 0x18,
0x47, 0xBD, 0xE0, 0x18, 0x45, 0xA5, 0xA0, 0x1E, 0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1A,
0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1A, 0x45, 0xA5, 0xA0, 0x1E, 0x47, 0xBD, 0xE0, 0x18,
0x47, 0x3C, 0xE0, 0x18, 0x40, 0x00, 0x00, 0x10, 0x3F, 0xFF, 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
};
const unsigned char PROGMEM temperatura [] = {
0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x04, 0x20, 0x00,
0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00,
0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00,
0x00, 0x04, 0x20, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00,
0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x05, 0xA0, 0x00, 0x00, 0x0D, 0xB0, 0x00,
0x00, 0x19, 0x98, 0x00, 0x00, 0x33, 0xCC, 0x00, 0x00, 0x26, 0x64, 0x00, 0x00, 0x6C, 0x36, 0x00,
0x00, 0x68, 0x16, 0x00, 0x00, 0x68, 0x16, 0x00, 0x00, 0x2C, 0x34, 0x00, 0x00, 0x27, 0xE4, 0x00,
0x00, 0x33, 0xCC, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x01, 0x80, 0x00
};
const unsigned char PROGMEM continu [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1F, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0xFF, 0xF0,
0x1F, 0xC0, 0x03, 0xF8, 0x7F, 0x00, 0x00, 0xFE, 0xFC, 0x00, 0x00, 0x3F, 0xF8, 0x07, 0xE0, 0x1F,
0xF0, 0x3F, 0xFC, 0x0F, 0x00, 0xFF, 0xFF, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x03, 0xF0, 0x0F, 0xC0,
0x07, 0xC0, 0x03, 0xE0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0x0F, 0xF0, 0x80, 0x00, 0x1F, 0xF8, 0x00,
0x00, 0x3F, 0xFC, 0x00, 0x00, 0x3C, 0x3C, 0x00, 0x00, 0x38, 0x1C, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM resis [] = {
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x0F, 0x88,
0x00, 0x00, 0x18, 0xD0, 0x00, 0x00, 0x38, 0x60, 0x00, 0x00, 0x6C, 0x30, 0x00, 0x00, 0xC6, 0x18,
0x00, 0x00, 0x83, 0x08, 0x00, 0x01, 0x81, 0x8C, 0x00, 0x03, 0x00, 0xCC, 0x00, 0x07, 0x80, 0x78,
0x00, 0x0C, 0xC0, 0x30, 0x00, 0x18, 0x60, 0x60, 0x00, 0x38, 0x30, 0xC0, 0x00, 0x6C, 0x1B, 0x80,
0x01, 0xC6, 0x0E, 0x00, 0x03, 0x03, 0x0C, 0x00, 0x07, 0x01, 0x98, 0x00, 0x0D, 0x80, 0xF0, 0x00,
0x18, 0xC0, 0x60, 0x00, 0x30, 0x60, 0xC0, 0x00, 0x30, 0x31, 0x80, 0x00, 0x10, 0x19, 0x00, 0x00,
0x18, 0x0F, 0x00, 0x00, 0x0C, 0x06, 0x00, 0x00, 0x06, 0x0C, 0x00, 0x00, 0x0B, 0x18, 0x00, 0x00,
0x11, 0xF0, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00
};
const unsigned char PROGMEM dioda [] = {
0x00, 0x07, 0xE0, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x78, 0x1E, 0x00,
0x00, 0xE0, 0x07, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x01, 0xC0, 0x03, 0x80,
0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80,
0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x07, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xE0,
0x07, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00,
0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00,
0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00, 0x00, 0x1C, 0x38, 0x00
};
const unsigned char PROGMEM ime [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 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, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0x00, 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xE0, 0xFF, 0xF9, 0xFF, 0x00, 0xFF, 0xFD, 0xFF, 0xFC, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xF1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x7E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xE7, 0xF9, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0xFF, 0xE0, 0x3F, 0xC7, 0xFF, 0xEF, 0xDF, 0x80, 0x0F, 0x80, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0x3F, 0xC0, 0x1F, 0x83, 0xE7, 0xC3, 0x0F, 0x00, 0x07, 0x80, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0x1F, 0x80, 0x0F, 0x03, 0x83, 0xC3, 0x06, 0x00, 0x07, 0x80, 0x00, 0x00,
0x00, 0x00, 0x03, 0x8E, 0x1F, 0x9C, 0x07, 0x03, 0x83, 0x83, 0x8E, 0x00, 0x03, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0x8F, 0x0F, 0x9C, 0x07, 0x01, 0x83, 0x83, 0x8E, 0x0F, 0x83, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0x9F, 0x87, 0x3C, 0x07, 0x00, 0x03, 0x87, 0x9C, 0x1F, 0xC3, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0x9F, 0x87, 0x1C, 0x06, 0x00, 0x03, 0x07, 0x3C, 0x1F, 0xC3, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xDF, 0x87, 0x00, 0x02, 0x0C, 0x03, 0x06, 0x3E, 0x1F, 0xC1, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xCF, 0x82, 0x00, 0x02, 0x0E, 0x03, 0x00, 0x3E, 0x1F, 0xC1, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xCF, 0x82, 0x1C, 0x06, 0x0E, 0x03, 0x06, 0x1E, 0x1F, 0xC3, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC7, 0x82, 0x3C, 0x06, 0x0E, 0x06, 0x07, 0x0E, 0x0F, 0x83, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0x00, 0x1C, 0x06, 0x0E, 0x06, 0x07, 0x8F, 0x07, 0x03, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0x04, 0x1C, 0x0E, 0x0E, 0x07, 0x03, 0x8F, 0x80, 0x07, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xC0, 0x0E, 0x1C, 0x0E, 0x0E, 0x07, 0x03, 0x0F, 0x80, 0x0F, 0x80, 0x00, 0x00,
0x00, 0x00, 0x01, 0xC0, 0x1E, 0x18, 0x1E, 0x1E, 0x0F, 0x83, 0x0F, 0xE0, 0x3F, 0x80, 0x00, 0x00,
0x00, 0x00, 0x01, 0xE0, 0x3F, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFB, 0xFF, 0xF7, 0xFF, 0xFC, 0xFF, 0xFC, 0x7F, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int pauza = 300;
int raw = 0;
float Vin = 0;
float Vout = 0;
float R1 = 2000;
float R2 = 0;
float vout2 = 0.00;
float vin2 = 0.00;
float res1 = 100000.00; // resistance of R1 (100K)
float res2 = 10000.00; // resistance of R2 (10K)
int val = 0;
float buffer = 0;
void setup() {
sensors.begin();
pinMode(5, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(13, OUTPUT);
attachInterrupt(1, pritisnuto, FALLING);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done
display.clearDisplay();
display.drawBitmap(0, 0, ime, 128, 32, 1);
display.display();
delay(700);
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() / 1000.0;
val = analogRead(7);
vout2 = (val * volt3) / 1024.0; // see text
vin2 = vout2 / (res2 / (res1 + res2));
display.clearDisplay();
display.setFont();
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print("VOLTMETER:");
display.setCursor(80, 0);
display.print(volt3);
display.setFont(&FreeSans9pt7b);
display.setCursor(0, 24);
display.print(vin2 + 0.1);
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)
{ // ohm meter
display.clearDisplay();
display.setFont();
display.setCursor(0, 0);
display.print("RESISTANCE:");
display.drawBitmap(96, 0, resis, 32, 32, 1);
raw = analogRead(A2);
Vin = readVcc() / 1000.0;
buffer = raw * Vin;
Vout = (buffer) / 1024.0;
buffer = (Vin / Vout) - 1;
R2 = R1 * buffer;
display.setFont(&FreeSans12pt7b);
display.setCursor(0, 28);
if (R2 < 70000)
display.print(R2);
if (R2 > 70000)
display.print("empty");
display.display();
delay(pauza);
}
if (stisnuto == 3) //dioda drop
{
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)
{ //continuiti
display.clearDisplay();
display.drawBitmap(96, 0, continu, 32, 32, 1);
display.setFont();
display.setCursor(0, 0);
display.print("CONTINUITY TEST:");
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)
{//temp
noTone(6);
sensors.requestTemperatures();
float temp= sensors.getTempCByIndex(0);
display.clearDisplay();
display.drawBitmap(96, 0, temperatura, 32, 32, 1);
display.setFont();
display.setCursor(0,0);
display.print("TEMPERATURE:");
display.setFont(&FreeSans12pt7b);
display.setCursor(0,28);
display.print(temp-2);
display.setCursor(70,28);
display.print("C");
display.display();
delay(pauza);
}
*/
if (stisnuto == 6)
{ //baterry
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 == 7)
{
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();
}
}
void pritisnuto()
{
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
// If interrupts come faster than 200ms, assume it's a bounce and ignore
if (interrupt_time - last_interrupt_time > 220)
{
stisnuto++;
tone(6, 2250, 50);
if (stisnuto > 7)
stisnuto = 0;
}
last_interrupt_time = interrupt_time;
}
long readVcc() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#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); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA, ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high << 8) | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
ERROR:
Arduino: 1.8.13 (Windows 7), Board: "Arduino Uno"
E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\Arduino Multimeter and Components
Tester\multifunctionArduino_M\multifunctionArduino_M.ino: In function 'void setup
()':multifunctionArduino_M:179:3: error: 'sensors' was not declared in this scope sensors.begin();
^~~~~~~exit status 1'sensors' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.