Hledal jsem to, ale asi špatně.
Kód: Vybrat vše
// ILC Clock using 8 ILC VFD displays
// Last Updated: 05-10-19
// Displays Time, Date, Temperature, Humidity, and Pressure, and chimes
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <IRremote.h>
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini mp3;
#include <SparkFunBME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
BME280 bme; //Uses I2C address 0x76 (jumper closed)
#include "RTClib.h"
char key_pressed = 0;
int RECV_PIN = A0;
IRrecv irrecv(RECV_PIN);
decode_results results;
RTC_DS3231 rtc;
#define IR_CROSS 0xFFB04F // cross
/* two dimentional array for holdinPing MAX6921 chip dataPinbyte values
Grid 1 Grid 2 Grid 3 Grid 4 Grid 5 Grid 6 Grid 7 Grid 8 Grid 9 Grid 10 Grid 11 Grid 12
OUT11 OUT10 OUT9 OUT8 OUT7 OUT6 OUT5 OUT4 OUT3 OUT2 OUT1 OUT0
PIN 11 12 17 18 19 20 21 22 23 24 25 26
seg. A seg. B seg. C seg. D seg. E seg. F seg. G seg. DP
OUT12 OUT13 OUT14 OUT15 OUT16 OUT17 OUT18 OUT19
PIN 10 9 8 7 6 5 4 3
*/
int rows = 0;
int columns = 0;
int clockPin = 25; // 25,27,29
int loadPin = 27;
int dinPin = 29;
int dataPinRegister[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int offset;
//A F B G E C D,dp
int segmentArray[33][8]={
{ 1,1,1,0,1,1,1,0, }, //0
{ 0,0,1,0,0,1,0,0, }, //1
{ 1,0,1,1,1,0,1,0, }, //2
{ 1,0,1,1,0,1,1,0, }, //3
{ 0,1,1,1,0,1,0,0, }, //4
{ 1,1,0,1,0,1,1,0, }, //5
{ 1,1,0,1,1,1,1,0, }, //6
{ 1,0,1,0,0,1,0,0, }, //7
{ 1,1,1,1,1,1,1,0, }, //8
{ 1,1,1,1,0,1,0,0, }, //9
{ 1,1,1,0,1,1,1,1, }, //0.
{ 0,0,1,0,0,1,0,1, }, //1.
{ 1,0,1,1,1,0,1,1, }, //2.
{ 1,0,1,1,0,1,1,1, }, //3.
{ 0,1,1,1,0,1,0,1, }, //4.
{ 1,1,0,1,0,1,1,1, }, //5.
{ 1,1,0,1,1,1,1,1, }, //6.
{ 1,0,1,0,0,1,0,1, }, //7.
{ 1,1,1,1,1,1,1,1, }, //8.
{ 1,1,1,1,0,1,0,1, }, //9.
{ 0,0,0,1,0,0,0,0, }, //- G segment / W
{ 1,1,0,0,1,0,1,0, }, //C
{ 1,1,0,1,1,0,0,0, }, //F
{ 1,1,1,1,1,0,0,0, }, //P
{ 0,0,0,0,0,0,0,1, }, //.
{ 1,1,1,1,0,0,0,0, }, //Upper o
{ 0,0,1,1,1,0,0,0, }, // Slash
{ 0,0,0,1,1,1,1,0, }, //Lower o
{ 0,0,0,0,0,0,0,0, }, // Blank
{ 0,1,1,1,1,1,0,0, }, // H
{ 0,0,0,0,0,1,0,0, }, //- C segment X
{ 0,0,0,0,0,0,1,0, }, //- D segment Y
{ 0,0,0,0,1,0,0,0, }}; //- E segment Z
int field_value,test;
//Specify digital pin on the Arduino that the positive lead of piezo buzzer is attached.
int days = 11;
int months = 3;
int years = 19;
int new_days = 11;
int new_months = 3;
int new_years = 19;
int hours = 16;
int minutes = 11;
int seconds = 20;
int new_hours = 16;
int new_minutes = 11;
int new_seconds = 20;
int found, maxIndex;
int digits_entered = 0;
int j,x,y,k,m,n,i,t,a;
int index1;
int chimesVolumn = 20;
int ldrStatus; // Ambiant light check, less than 600 clock switches off
int ldrLimit = 200;
int sleep_mode = 0;
char testChar,indicator;
String screenSaveRequired;
String chimesRequired = "Y";
String chimesPlayed = "N";
String c_check;
String new_value_1, new_value_2;
String dayString;
String monthString;
String yearString;
String day1,day2;
String month1,month2;
String year1,year2,year3, year4;
String hourString;
String minuteString;
String secondString;
String hour1;
String minute1;
String second1;
String hour2;
String minute2;
String second2,save_second2;
String year_string,date_string;
String timeString, dateString;
String characterArray[7]; // Character Array
String humidityString;
String humidityString1;
String humidityString2;
String pressureString;
String pressureString1;
String pressureString2;
String temperatureCString;
String temperatureCString1;
String temperatureCString2;
String temperatureFString;
String temperatureFString1;
String temperatureFString2;
int pressure,temperatureC, temperatureF, humidity;
DateTime now;
void setup()
{
// initialize outputs for MAX6921 chip
pinMode(dinPin, OUTPUT);
pinMode(loadPin, OUTPUT);
pinMode(clockPin, OUTPUT);
digitalWrite(clockPin, LOW);
digitalWrite(loadPin, LOW);
digitalWrite(dinPin, LOW);
irrecv.enableIRIn();
// initialize the lcd
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("ILC Clock v.IR.1");
rtc.begin(); // Initialize the rtc object
// rtc.adjust(DateTime(2019, 10, 5, 11, 59, 0));
Wire.begin();
bme.setI2CAddress(0x76); //Connect to a second sensor 0x76
if(bme.beginI2C() == false)
{
Serial.println("Sensor B connect failed");
}
indicator = 'W'; // first part of rolling time seperator
sleep_mode = 0;
screenSaveRequired = "Y";
chimesPlayed = "N";
// setup chimes
mySoftwareSerial.begin(9600);
mp3.begin(mySoftwareSerial);
mp3.reset();
mp3.volume(30); //Set volume value. From 0 to 30
}
void loop()
{
// Check that light levels are OK, if dark then switch off Nixie tubes until
// light levels return to full.
light_detection();
if (sleep_mode != 1) {
DateTime now = rtc.now();
// Display time for 30 seconds
display_time();
lcd_display();
// equates to a display time of 40 seconds = 4200
for (t = 1; t <= 100; t++)
{
check_user_input();
// Display time on VFD screen
display_time();
// Check for Chime
if (chimesRequired == "Y" && chimesPlayed == "N") {
c_check = characterArray[3] + characterArray[4];
if (c_check == "00" || c_check == "15" || c_check == "30" || c_check == "45") {
play_chimes();
chimesPlayed = "Y";
}
}
}
chimesPlayed = "N";
// Display date
dayString = now.day();
// Display date on VFD screen
display_date();
lcd_display();
// equates to a display time of 5 seconds = 400
for (t = 1; t <= 50; t++)
{
check_user_input();
// Display date on VFD screen
display_date();
}
// Display temperature in Celisus
temperatureC = bme.readTempC();
// Display temperatureC on VFD screen
display_temperatureC();
lcd_display();
for (t = 1; t <= 50; t++)
{
check_user_input();
// Display temperatureC on VFD screen
display_temperatureC();
}
// Display pressure in mB
pressure = bme.readFloatPressure()/100.0F + 46;
// Display pressure on VFD screen
display_pressure();
lcd_display();
for (t = 1; t <= 50; t++)
{
check_user_input();
// Display pressure on VFD screen
display_pressure();
}
// Display humidity
humidity = bme.readFloatHumidity();
// Display humidity on VFD screen
display_humidity();
lcd_display();
for (t = 1; t <= 50; t++)
{
check_user_input();
// Display humidity on VFD screen
display_humidity();
}
}
}
void light_detection()
{
ldrStatus = analogRead(A15);
// Adjustment for difference between this clock and the original clock
// this will ensure that both clocks switch off approximately at the same time.
ldrStatus = ldrStatus * 100;
sleep_mode = 0;
if (ldrStatus <= ldrLimit && screenSaveRequired == "Y") {
sleep_mode = 1;
// Setup Blank Screen
characterArray[0] = " ";
characterArray[1] = " ";
characterArray[2] = " ";
characterArray[3] = " ";
characterArray[4] = " ";
characterArray[5] = " ";
characterArray[6] = " ";
characterArray[7] = " ";
lcd.setCursor(0,1);
lcd.print(" SLEEP MODE ");
process_display();
}
}
// Funkce pro nacteni a prevod kodu z IR ovladace na znaky '0' az '9' a '#'
char convert_key ()
{
char Ret = 0;
results.value = 0;
// nacteni kodu z IR ovladace
if (irrecv.decode(&results)) {
// uspesne nacteno, prikazem resume povolime dalsi cteni do budocuna
irrecv.resume();
} else {
// nenacteno
results.value = 0;
}
delay(100);
switch (results.value) {
case 0xFF9867:
// predpokladam, ze toto ma byt znak char '0' tj. hodnota dekadicky 48
Ret = 48;
break;
case 0xFFA25D:
// predpokladam, ze toto ma byt znak char '1' tj. hodnota dekadicky 49
Ret = 49;
break;
case 0xFF629D:
// predpokladam, ze toto ma byt znak char '2' tj. hodnota dekadicky 50
Ret = 50;
break;
case 0xFFE21D:
// predpokladam, ze toto ma byt znak char '3' tj. hodnota dekadicky 51
Ret = 51;
break;
case 0xFF22DD:
// predpokladam, ze toto ma byt znak char '4' tj. hodnota dekadicky 52
Ret = 52;
break;
case 0xFF02FD:
// predpokladam, ze toto ma byt znak char '5' tj. hodnota dekadicky 53
Ret = 53;
break;
case 0xFFC23D:
// predpokladam, ze toto ma byt znak char '6' tj. hodnota dekadicky 54
Ret = 54;
break;
case 0xFFE01F:
// predpokladam, ze toto ma byt znak char '7' tj. hodnota dekadicky 55
Ret = 55;
break;
case 0xFFA857:
// predpokladam, ze toto ma byt znak char '8' tj. hodnota dekadicky 56
Ret = 56;
break;
case 0xFF906F:
// predpokladam, ze toto ma byt znak char '9' tj. hodnota dekadicky 57
Ret = 57;
break;
case 0xFFB04F:
// predpokladam, ze toto ma byt znak char '#' tj. hodnota dekadicky 35
Ret = 35;
break;
default:
// nepodporovany znak tj. vrací se hodnota 0
Ret = 0;
break;
}
return Ret;
}
void process_chime_display()
{
// Chime Screen
characterArray[0] = " ";
characterArray[1] = " ";
characterArray[2] = " ";
characterArray[3] = " ";
characterArray[4] = " ";
characterArray[5] = " ";
characterArray[6] = " ";
characterArray[7] = ".";
process_display();
}
void play_chimes()
{
if (c_check == "00") {
// Sound hourly chime
c_check = characterArray[0] + characterArray[1];
process_chime_display();
mp3.play(16);
delay(19000);
if (c_check == "01" || c_check == "13") {
// Play 1 Hour Chime
mp3.play(1);
delay(3000);
}
if (c_check == "02" || c_check == "14") {
// Play 2 Hour Chime
mp3.play(2);
delay(5000);
}
if (c_check == "03" || c_check == "15") {
// Play 3 Hour Chime
mp3.play(3);
delay(7000);
}
if (c_check == "04" || c_check == "16") {
// Play 4 Hour Chime
mp3.play(4);
delay(9000);
}
if (c_check == "05" || c_check == "17") {
// Play 5 Hour Chime
mp3.play(5);
delay(11000);
}
if (c_check == "06" || c_check == "18") {
// Play 6 Hour Chime
mp3.play(6);
delay(13000);
}
if (c_check == "07" || c_check == "19") {
// Play 7 Hour Chime
mp3.play(7);
delay(15000);
}
if (c_check == "08" || c_check == "20") {
// Play 8 Hour Chime
mp3.play(8);
delay(17000);
}
if (c_check == "09" || c_check == "21") {
// Play 9 Hour Chime
mp3.play(9);
delay(19000);
}
if (c_check == "10" || c_check == "22") {
// Play 10 Hour Chime
mp3.play(10);
delay(21000);
}
if (c_check == "11" || c_check == "23") {
// Play 11 Hour Chime
mp3.play(11);
delay(23000);
}
if (c_check == "12" || c_check == "00") {
// Play 12 Hour Chime
mp3.play(12);
delay(25000);
}
} else {
process_chime_display();
if (c_check == "15") {
// play 15 Minute chime
mp3.play(13);
}
if (c_check == "30") {
// play 30 Minute chime
mp3.play(14);
}
if (c_check == "45") {
// play 45 Minute chime
mp3.play(15);
}
}
}
void check_user_input()
{
key_pressed = convert_key();
if (key_pressed != 0) {
if (key_pressed == '#') {
adjustValues();
}
}
}
// Display on the LCD exactly what is stored in the character array.
void lcd_display()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("ILC Clock IR 1.0");
lcd.setCursor(1,1);
lcd.print(characterArray[0]);
lcd.print(characterArray[1]);
if (characterArray[2] == "W" || characterArray[2] == "X" ||
characterArray[2] == "Y" || characterArray[2] == "Z") {
lcd.print(".");
} else {
lcd.print(characterArray[2]);
}
lcd.print(characterArray[3]);
lcd.print(characterArray[4]);
if (characterArray[2] == "W" || characterArray[2] == "X" ||
characterArray[2] == "Y" || characterArray[2] == "Z") {
lcd.print(".");
} else {
lcd.print(characterArray[5]);
}
lcd.print(characterArray[6]);
lcd.print(characterArray[7]);
}
void display_time()
{
now = rtc.now();
hourString = now.hour();
test = hourString.length();
if (test == 1) {
hour1 = " ";
hour2 = hourString.substring(0,1);
} else {
hour1 = hourString.substring(0,1);
hour2 = hourString.substring(1,2);
}
minuteString = now.minute();
test = minuteString.length();
if (test == 1) {
minute1 = "0";
minute2 = minuteString.substring(0,1);
} else {
minute1 = minuteString.substring(0,1);
minute2 = minuteString.substring(1,2);
}
secondString = now.second();
test = secondString.length();
if (test == 1) {
second1 = "0";
second2 = secondString.substring(0,1);
} else {
second1 = secondString.substring(0,1);
second2 = secondString.substring(1,2);
}
characterArray[0] = hour1;
characterArray[1] = hour2;
characterArray[2] = indicator;
characterArray[3] = minute1;
characterArray[4] = minute2;
characterArray[5] = indicator;
characterArray[6] = second1;
characterArray[7] = second2;
if (second2 != save_second2) {
// Move the indicator one position at the change of each second
if (indicator == 'W') {
indicator = 'X';
} else if (indicator == 'X') {
indicator = 'Y';
} else if (indicator == 'Y') {
indicator = 'Z';
} else {
indicator = 'W';
}
save_second2 = second2;
}
// Test Array
// characterArray[0] = "0";
// characterArray[1] = "1";
// characterArray[2] = "2";
// characterArray[3] = "3";
// characterArray[4] = "4";
// characterArray[5] = "5";
// characterArray[6] = "6";
// characterArray[7] = "7";
process_display();
}
void display_date()
{
now = rtc.now();
dayString = now.day();
test = dayString.length();
if (test == 1) {
day1 = " ";
day2 = dayString.substring(0,1);
} else {
day1 = dayString.substring(0,1);
day2 = dayString.substring(1,2);
}
monthString = now.month();
test = monthString.length();
if (test == 1) {
month1 = "0";
month2 = monthString.substring(0,1);
} else {
month1 = monthString.substring(0,1);
month2 = monthString.substring(1,2);
}
yearString = now.year();
year1 = yearString.substring(0,1);
year2 = yearString.substring(1,2);
year3 = yearString.substring(2,3);
year4 = yearString.substring(3,4);
characterArray[0] = day1;
characterArray[1] = day2;
characterArray[2] = "-";
characterArray[3] = month1;
characterArray[4] = month2;
characterArray[5] = "-";
characterArray[6] = year3;
characterArray[7] = year4;
process_display();
}
void display_temperatureC()
{
temperatureCString = String(temperatureC);
temperatureCString1 = getValue(temperatureCString, ' ', 0); // 99.
temperatureCString2 = getValue(temperatureCString, ' ', 1); // .99
characterArray[0] = " ";
characterArray[1] = temperatureCString1.substring(0,1);
characterArray[2] = temperatureCString1.substring(1,2);
characterArray[3] = " ";
characterArray[4] = temperatureCString2.substring(0,1);
characterArray[5] = temperatureCString2.substring(1,2);
characterArray[6] = "";
characterArray[7] = "C";
process_display();
}
void display_pressure()
{
pressureString = String(pressure);
pressureString1 = getValue(pressureString, ' ', 0); // 9999.
pressureString2 = getValue(pressureString, ' ', 1); // .99
if (pressureString1.substring(0,1) == "9") {
// correctly display pressure values less than 1000 mB
characterArray[0] = " ";
characterArray[1] = pressureString1.substring(0,1);
characterArray[2] = pressureString1.substring(1,2);
characterArray[3] = pressureString1.substring(2,3);
} else {
characterArray[0] = pressureString1.substring(0,1);
characterArray[1] = pressureString1.substring(1,2);
characterArray[2] = pressureString1.substring(2,3);
characterArray[3] = pressureString1.substring(3,4);
}
characterArray[4] = " ";
characterArray[5] = pressureString2.substring(0,1);
characterArray[6] = pressureString2.substring(1,2);
characterArray[7] = "P";
process_display();
}
void display_humidity()
{
humidityString = String(humidity);
humidityString1 = getValue(humidityString, ' ', 0); // 99.
humidityString2 = getValue(humidityString, ' ', 1); // .99
characterArray[0] = humidityString2.substring(0,1);
characterArray[1] = humidityString2.substring(1,2);
characterArray[2] = " ";
characterArray[3] = humidityString1.substring(0,1);
characterArray[4] = humidityString1.substring(1,2);
characterArray[5] = " o";
characterArray[6] = "/";
characterArray[7] = "o";
process_display();
}
void adjustValues()
{
now = rtc.now();
// get current time and date, populate adjustment fields.
hourString = now.hour();
minuteString = now.minute();
secondString = now.second();
hour1 = hourString.substring(0,2);
minute1 = minuteString.substring(0,2);
second1 = secondString.substring(0,2);
dayString = now.day();
monthString = now.month();
yearString = now.year();
day1 = dayString.substring(0,2);
month1 = monthString.substring(0,2);
year1 = yearString.substring(2,4);
new_days = day1.toInt();
new_months = month1.toInt();
new_years = year1.toInt();
new_hours = hour1.toInt();
new_minutes = minute1.toInt();
new_seconds = second1.toInt();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Clock Adjustment");
delay(700);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Days(DD): ");
lcd.print(new_days);
adjust_field(1);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Months(MM): ");
lcd.print(new_months);
adjust_field(2);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Years(YY): ");
lcd.print(new_years);
adjust_field(3);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Hours(HH): ");
lcd.print(new_hours);
adjust_field(4);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Minutes(MM): ");
lcd.print(new_minutes);
adjust_field(5);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Seconds(SS): ");
lcd.print(new_seconds);
adjust_field(6);
delay(200);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Set:1=Y/0=N ");
lcd.setCursor(0,0);
lcd.print("Chimes: ");
lcd.print(chimesRequired);
adjust_field(7);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Volume(VV): ");
lcd.print(chimesVolumn);
adjust_field(8);
delay(200);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Set:1=Y/0=N ");
lcd.setCursor(0,0);
lcd.print("Screen Save: ");
lcd.print(screenSaveRequired);
adjust_field(9);
delay(200);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" New Values Set");
mp3.volume(chimesVolumn); //Set volume value. From 0 to 30
new_years = 2000 + new_years;
rtc.adjust(DateTime(new_years, new_months, new_days, new_hours, new_minutes, new_seconds));
}
void adjust_field(int field)
{
field_value = field;
digits_entered = 13;
key_pressed = convert_key();
while (key_pressed != '#')
{
if (key_pressed == '0' || key_pressed == '1' || key_pressed == '2' ||
key_pressed == '3' || key_pressed == '4' || key_pressed == '5' ||
key_pressed == '6' || key_pressed == '7' || key_pressed == '8' ||
key_pressed == '9') {
if (digits_entered == 13) {
lcd.setCursor(digits_entered,0);
digits_entered = digits_entered + 1;
lcd.print(key_pressed);
} else {
if (digits_entered == 14) {
lcd.setCursor(digits_entered,0);
digits_entered = digits_entered + 1;
lcd.print(key_pressed);
} else {
display_Error(2);
digits_entered = 13;
}
}
switch (field_value) {
case 1:
if (digits_entered == 14) {
new_days = (int)key_pressed - 48;
} else {
new_days = (new_days * 10) + (int)key_pressed - 48;
}
break;
case 2:
if (digits_entered == 14) {
new_months = (int)key_pressed - 48;
} else {
new_months = (new_months * 10) + (int)key_pressed - 48;
}
break;
case 3:
if (digits_entered == 14) {
new_years = (int)key_pressed - 48;
} else {
new_years = (new_years * 10) + (int)key_pressed - 48;
}
break;
case 4:
if (digits_entered == 14) {
new_hours = (int)key_pressed - 48;
} else {
new_hours = (new_hours * 10) + (int)key_pressed - 48;
}
break;
case 5:
if (digits_entered == 14) {
new_minutes = (int)key_pressed - 48;
} else {
new_minutes = (new_minutes * 10) + (int)key_pressed - 48;
}
break;
case 6:
if (digits_entered == 14) {
new_seconds = (int)key_pressed - 48;
} else {
new_seconds = (new_seconds * 10) + (int)key_pressed - 48;
}
break;
case 7:
if ((int)key_pressed - 48 == 1) {
chimesRequired = "Y";
} else {
chimesRequired = "N";
}
break;
case 8:
if (digits_entered == 14) {
chimesVolumn = (int)key_pressed - 48;
} else {
chimesVolumn = (chimesVolumn * 10) + (int)key_pressed - 48;
}
break;
case 9:
if ((int)key_pressed - 48 == 1) {
screenSaveRequired = "Y";
} else {
screenSaveRequired = "N";
}
break;
}
}
key_pressed = 0;
// Wait for user to press a key on the keypad
while (key_pressed == 0)
{
key_pressed = convert_key();
delay(100);
}
}
}
void display_Error(int type)
{
lcd.setCursor(0,1);
if (type == 1 ) {
lcd.print(" Invalid Entry ");
} else {
lcd.print("Too many digits ");
}
delay (200);
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
if (field_value == 1) {
lcd.print(" Days(DD): ");
new_days = day1.toInt();
lcd.print(new_days);
}
if (field_value == 2) {
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print(" Months(MM): ");
new_months = month1.toInt();
lcd.print(new_months);
}
if (field_value == 3) {
lcd.print(" Years(YY): ");
new_years = year1.toInt();
lcd.print(new_years);
}
if (field_value == 4) {
lcd.print(" Hours(HH): ");
new_hours = hour1.toInt();
lcd.print(new_hours);
}
if (field_value == 5) {
lcd.print("Minutes(MM): ");
new_minutes = minute1.toInt();
lcd.print(new_minutes);
}
if (field_value == 6) {
lcd.print("Seconds(SS): ");
new_seconds = second1.toInt();
lcd.print(new_seconds);
}
if (field_value == 8) {
lcd.print("Volume(VV): ");
lcd.print(chimesVolumn);
}
}
String getValue(String dataPin, char separator, int index2)
{
found = 0;
int strIndex[] = { 0, -1 };
maxIndex = dataPin.length() - 1;
for (i = 0; i <= maxIndex && found <= index2; i++)
{
if (dataPin.charAt(i) == separator || i == maxIndex) {
found++;
strIndex[0] = strIndex[1] + 1;
strIndex[1] = (i == maxIndex) ? i+1 : i;
}
}
return found > index2 ? dataPin.substring(strIndex[0], strIndex[1]) : "";
}
void write_loadPin()
{
digitalWrite(loadPin, HIGH);
digitalWrite(loadPin, LOW);
}
void write_clockPin()
{
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
void write_character()
{
if (characterArray[7-offset] == "0") index1 = 0;
if (characterArray[7-offset] == "1") index1 = 1;
if (characterArray[7-offset] == "2") index1 = 2;
if (characterArray[7-offset] == "3") index1 = 3;
if (characterArray[7-offset] == "4") index1 = 4;
if (characterArray[7-offset] == "5") index1 = 5;
if (characterArray[7-offset] == "6") index1 = 6;
if (characterArray[7-offset] == "7") index1 = 7;
if (characterArray[7-offset] == "8") index1 = 8;
if (characterArray[7-offset] == "9") index1 = 9;
if (characterArray[7-offset] == "0.") index1 = 10;
if (characterArray[7-offset] == "1.") index1 = 11;
if (characterArray[7-offset] == "2.") index1 = 12;
if (characterArray[7-offset] == "3.") index1 = 13;
if (characterArray[7-offset] == "4.") index1 = 14;
if (characterArray[7-offset] == "5.") index1 = 15;
if (characterArray[7-offset] == "6.") index1 = 16;
if (characterArray[7-offset] == "7.") index1 = 17;
if (characterArray[7-offset] == "8.") index1 = 18;
if (characterArray[7-offset] == "9.") index1 = 19;
if (characterArray[7-offset] == "-") index1 = 20;
if (characterArray[7-offset] == "C") index1 = 21;
if (characterArray[7-offset] == "F") index1 = 22;
if (characterArray[7-offset] == "P") index1 = 23;
if (characterArray[7-offset] == ".") index1 = 24;
if (characterArray[7-offset] == "O") index1 = 25;
if (characterArray[7-offset] == "/") index1 = 26;
if (characterArray[7-offset] == "o") index1 = 27;
if (characterArray[7-offset] == " ") index1 = 28;
if (characterArray[7-offset] == "H") index1 = 29;
if (characterArray[7-offset] == "W") index1 = 20;
if (characterArray[7-offset] == "X") index1 = 30;
if (characterArray[7-offset] == "Y") index1 = 31;
if (characterArray[7-offset] == "Z") index1 = 32;
}
void process_display()
{
for (offset = 7; offset >= 0; offset--) // was 9
{
write_character();
write_clockPin();
for (i = 19; i >= 0; i--)
{
if (i >= 12) {
dataPinRegister[i] = segmentArray[index1][i-12];
}
digitalWrite(dinPin, dataPinRegister[i]);
write_clockPin();
}
write_loadPin();
dataPinRegister[offset] = 0;
if (offset != 0) {
dataPinRegister[offset-1] = 1;
} else {
dataPinRegister[7] = 1; // was 9
}
delay(1);
}
}