#include <LiquidCrystal_I2C.h>
byte v1[8] = { 0, 0, 0, 0, 0, 0, 0, 31};
byte v2[8] = { 0, 0, 0, 0, 0, 0, 31, 31};
byte v3[8] = { 0, 0, 0, 0, 0, 31, 31, 31};
byte v4[8] = { 0, 0, 0, 0, 31, 31, 31, 31};
byte v5[8] = { 0, 0, 0, 31, 31, 31, 31, 31};
byte v6[8] = { 0, 0, 31, 31, 31, 31, 31, 31};
byte v7[8] = { 0, 31, 31, 31, 31, 31, 31, 31};
byte v8[8] = {31, 31, 31, 31, 31, 31, 31, 31};
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("AM 1040 kHz");
}
void loop()
{
Bars();
}
void Bars()
{
lcd.createChar(0, v1);
lcd.createChar(1, v2);
lcd.createChar(2, v3);
lcd.createChar(3, v4);
lcd.createChar(4, v5);
lcd.createChar(5, v6);
lcd.createChar(6, v7);
lcd.createChar(7, v8);
int posLevel = map(analogRead(A1), 0, 1023, 0, 7);
if (posLevel > 7)
{
lcd.setCursor(1, 1);
lcd.write((uint8_t)posLevel - 7);
lcd.setCursor(14, 0);
lcd.write((uint8_t)8);
}
if (posLevel <= 7)
{
lcd.setCursor(1, 1);
lcd.print(" ");
lcd.setCursor(14, 0);
lcd.write((uint8_t)posLevel);
}
delay(10);
}