#include <PrintCascade.h>
#include <SerialDebug.h>
#include <NewSoftSerial.h>
#include <LiquidCrystal.h>
#include <string.h>
#include <stdlib.h>
#define RS 14 //[ch1048][ch1079][ch1073][ch1077][ch1088][ch1080]/[ch1054][ch1087][ch1088][ch1077][ch1076][ch1077][ch1083][ch1080] [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] Arduino [ch1082][ch1086][ch1081][ch1090][ch1086] [ch1097][ch1077] [ch1077] [ch1089][ch1074][ch1098][ch1088][ch1079][ch1072][ch1085] [ch1082][ch1098][ch1084] [ch1079][ch1072] REGISTER SELECT (RS) [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] LCD [ch1076][ch1080][ch1089][ch1087][ch1083][ch1077][ch1081][ch1103]
//[ch1058][ch1086][ch1079][ch1080] [ch1088][ch1077][ch1075][ch1080][ch1089][ch1090][ch1098][ch1088] [ch1086][ch1087][ch1088][ch1077][ch1076][ch1077][ch1083][ch1103] [ch1082][ch1098][ch1076][ch1077] [ch1097][ch1077] [ch1089][ch1077] [ch1079][ch1072][ch1087][ch1080][ch1089][ch1074][ch1072] [ch1080][ch1085][ch1092][ch1086][ch1088][ch1084][ch1072][ch1094][ch1080][ch1103][ch1090][ch1072]([ch1074] [ch1082][ch1086][ch1081] [ch1088][ch1077][ch1075][ch1080][ch1089][ch1090][ch1098][ch1088])[ch1074] [ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088][ch1072] [ch1085][ch1072] [ch1051][ch1062][ch1044].[ch1052][ch1086][ch1078][ch1077] [ch1076][ch1072] [ch1080][ch1079][ch1073][ch1080][ch1088][ch1072][ch1084][ch1077] [ch1084][ch1077][ch1078][ch1076][ch1091]:
//[ch1056][ch1077][ch1075][ch1080][ch1089][ch1090][ch1098][ch1088][ch1072] [ch1079][ch1072] [ch1076][ch1072][ch1085][ch1085][ch1080] (DATA REGISTER) [ch1074] [ch1085][ch1077][ch1075][ch1086] [ch1089][ch1077] [ch1089][ch1098][ch1076][ch1098][ch1088][ch1078][ch1072]/[ch1089][ch1098][ch1093][ch1088][ch1072][ch1085][ch1103][ch1074][ch1072] [ch1090][ch1086][ch1074][ch1072] [ch1082][ch1086][ch1077][ch1090][ch1086] [ch1097][ch1077] [ch1089][ch1077] [ch1087][ch1086][ch1082][ch1072][ch1079][ch1074][ch1072] [ch1076][ch1080][ch1088][ch1077][ch1082][ch1090][ch1085][ch1086] [ch1085][ch1072] [ch1077][ch1082][ch1088][ch1072][ch1085][ch1072] [ch1085][ch1072] LCD-[ch1090][ch1086].
//[ch1056][ch1077][ch1075][ch1080][ch1089][ch1090][ch1098][ch1088] [ch1079][ch1072] [ch1080][ch1085][ch1089][ch1090][ch1088][ch1091][ch1082][ch1094][ch1080][ch1080] (INSTRUCTION REGISTER) [ch1086][ch1090] [ch1082][ch1086][ch1081][ch1090][ch1086] [ch1089][ch1086][ch1073][ch1089][ch1090][ch1074][ch1077][ch1085][ch1080][ch1103] [ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088] [ch1085][ch1072] LCD-[ch1090][ch1086] [ch1095][ch1077][ch1090][ch1077] [ch1080][ch1085][ch1092][ch1086][ch1088][ch1084][ch1072][ch1094][ch1080][ch1103]([ch1080][ch1085][ch1089][ch1090][ch1088][ch1091][ch1082][ch1094][ch1080][ch1080]) [ch1079][ch1072] [ch1090][ch1086][ch1074][ch1072] [ch1082][ch1072][ch1082][ch1074][ch1086] [ch1076][ch1072] [ch1087][ch1088][ch1072][ch1074][ch1080].
/////////#define RW 15 //[ch1048][ch1079][ch1073][ch1077][ch1088][ch1080]/[ch1054][ch1087][ch1088][ch1077][ch1076][ch1077][ch1083][ch1080] [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] Arduino [ch1082][ch1086][ch1081][ch1090][ch1086] [ch1097][ch1077] [ch1077] [ch1089][ch1074][ch1098][ch1088][ch1079][ch1072][ch1085] [ch1082][ch1098][ch1084] [ch1079][ch1072] READ/WRITE (RW) [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] LCD [ch1076][ch1080][ch1089][ch1087][ch1083][ch1077][ch1081][ch1103]
//[ch1048][ch1079][ch1073][ch1080][ch1088][ch1072] [ch1076][ch1072][ch1083][ch1080] [ch1076][ch1072] [ch1095][ch1077][ch1090][ch1077][ch1084] [ch1080][ch1085][ch1092][ch1086][ch1088][ch1084][ch1072][ch1094][ch1080][ch1103] [ch1086][ch1090] [ch1076][ch1080][ch1089][ch1087][ch1083][ch1077][ch1103] [ch1080][ch1083][ch1080] [ch1076][ch1072] [ch1079][ch1072][ch1087][ch1080][ch1089][ch1074][ch1072][ch1084][ch1077] [ch1074] [ch1085][ch1077][ch1075][ch1086].
#define E 4 //[ch1048][ch1079][ch1073][ch1077][ch1088][ch1080]/[ch1054][ch1087][ch1088][ch1077][ch1076][ch1077][ch1083][ch1080] [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] Arduino [ch1082][ch1086][ch1081][ch1090][ch1086] [ch1097][ch1077] [ch1077] [ch1089][ch1074][ch1098][ch1088][ch1079][ch1072][ch1085] [ch1082][ch1098][ch1084] [ch1079][ch1072] ENABLE (E) [ch1087][ch1080][ch1085][ch1072] [ch1085][ch1072] LCD [ch1076][ch1080][ch1089][ch1087][ch1083][ch1077][ch1081][ch1103]
//[ch1055][ch1086][ch1079][ch1074][ch1086][ch1083][ch1103][ch1074][ch1072]/[ch1056][ch1072][ch1079][ch1088][ch1077][ch1096][ch1072][ch1074][ch1072] [ch1079][ch1072][ch1087][ch1080][ch1089][ch1072] [ch1074] [ch1088][ch1077][ch1075][ch1080][ch1089][ch1090][ch1088][ch1080][ch1090][ch1077] [ch1085][ch1072] LCD-[ch1090][ch1086].
#define DB0 5
#define DB1 6
#define DB2 7
#define DB3 8
#define DB4 9
#define DB5 10
#define DB6 11
#define DB7 12
LiquidCrystal lcd(RS,E,DB0,DB1,DB2,DB3,DB4,DB5,DB6,DB7);
#define _a 0x61 //[ch1073][ch1091][ch1082][ch1074][ch1072] [ch1086][ch1090] [ch1082][ch1080][ch1088][ch1080][ch1083][ch1080][ch1094][ch1072][ch1090][ch1072] - "[ch1072]" [ch1086][ch1090][ch1075][ch1086][ch1074][ch1072][ch1088][ch1103] [ch1085][ch1072] [ch1072][ch1076][ch1088][ch1077][ch1089] [ch1086][ch1090] [ch1087][ch1072][ch1084][ch1077][ch1090][ch1090][ch1072] [ch1085][ch1072] [ch1089][ch1086][ch1073][ch1089][ch1090][ch1074][ch1077][ch1085][ch1080][ch1103] [ch1084][ch1080][ch1082][ch1088][ch1086][ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088] [ch1085][ch1072] LCD-[ch1090][ch1086].
#define _b 0xB2
#define _v 0xB3
#define _g 0xB4
#define _d 0xE3
#define _e 0x65
#define _j 0xB6
#define _z 0xB7
#define _i 0xB8 //[ch1073][ch1091][ch1082][ch1074][ch1072] [ch1086][ch1090] [ch1082][ch1080][ch1088][ch1080][ch1083][ch1080][ch1094][ch1072][ch1090][ch1072] - "[ch1072]" [ch1086][ch1090][ch1075][ch1086][ch1074][ch1072][ch1088][ch1103] [ch1085][ch1072] [ch1072][ch1076][ch1088][ch1077][ch1089] [ch1086][ch1090] [ch1087][ch1072][ch1084][ch1077][ch1090][ch1090][ch1072] [ch1085][ch1072] [ch1089][ch1086][ch1073][ch1089][ch1090][ch1074][ch1077][ch1085][ch1080][ch1103] [ch1084][ch1080][ch1082][ch1088][ch1086][ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088] [ch1085][ch1072] LCD-[ch1090][ch1086].
#define _ik 0xB9 // [ch1073][ch1091][ch1082][ch1074][ch1072] [ch1081] - ([ch1080] [ch1082][ch1088][ch1072][ch1090][ch1082][ch1086])
#define _k 0xBA
#define _l 0xBB
#define _m 0xBC
#define _n 0xBD
#define _o 0x6F
#define _p 0xBE
#define _r 0x70 //[ch1073][ch1091][ch1082][ch1074][ch1072] [ch1086][ch1090] [ch1082][ch1080][ch1088][ch1080][ch1083][ch1080][ch1094][ch1072][ch1090][ch1072] - "[ch1072]" [ch1086][ch1090][ch1075][ch1086][ch1074][ch1072][ch1088][ch1103] [ch1085][ch1072] [ch1072][ch1076][ch1088][ch1077][ch1089] [ch1086][ch1090] [ch1087][ch1072][ch1084][ch1077][ch1090][ch1090][ch1072] [ch1085][ch1072] [ch1089][ch1086][ch1073][ch1089][ch1090][ch1074][ch1077][ch1085][ch1080][ch1103] [ch1084][ch1080][ch1082][ch1088][ch1086][ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088] [ch1085][ch1072] LCD-[ch1090][ch1086].
#define _s 0x63
#define _t 0xBF
#define _u 0x79
#define _f 0xE4
#define _h 0x78
#define _c 0xE5
#define _ch 0xC0//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1095]"
#define _sh 0xC1//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1096]"
#define _sht 0xE6//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1097]"
#define _erm 0xC4 //[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1100]" - ([ch1077][ch1088] [ch1084][ch1072][ch1083][ch1098][ch1082])
#define _y 0xC2 //[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1098]"
#define _iu 0xC6//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1102]"
#define _q 0xC7 // [ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1103]"
//[ch1075][ch1083][ch1072][ch1074][ch1085][ch1080] [ch1073][ch1091][ch1082][ch1074][ch1080]
#define _A 0x41 //[ch1073][ch1091][ch1082][ch1074][ch1072] [ch1086][ch1090] [ch1082][ch1080][ch1088][ch1080][ch1083][ch1080][ch1094][ch1072][ch1090][ch1072] - "[ch1040]" [ch1086][ch1090][ch1075][ch1086][ch1074][ch1072][ch1088][ch1103] [ch1085][ch1072] [ch1072][ch1076][ch1088][ch1077][ch1089] [ch1086][ch1090] [ch1087][ch1072][ch1084][ch1077][ch1090][ch1090][ch1072] [ch1085][ch1072] [ch1089][ch1086][ch1073][ch1089][ch1090][ch1074][ch1077][ch1085][ch1080][ch1103] [ch1084][ch1080][ch1082][ch1088][ch1086][ch1082][ch1086][ch1085][ch1090][ch1088][ch1086][ch1083][ch1077][ch1088] [ch1085][ch1072] LCD-[ch1090][ch1086].
#define _B 0xA0
#define _V 0x42
#define _G 0xA1
#define _D 0xE0
#define _E 0x45
#define _J 0xA3
#define _Z 0xA4
#define _I 0xA5 //[ch1073][ch1091][ch1082][ch1074][ch1072] - "[ch1048]"
#define _Ik 0xA6 // [ch1073][ch1091][ch1082][ch1074][ch1072] [ch1049] - ([ch1080] [ch1082][ch1088][ch1072][ch1090][ch1082][ch1086])
#define _K 0x4B
#define _L 0xA7
#define _M 0x4D
#define _N 0x48
#define _O 0x4F
#define _P 0xA8
#define _R 0x50
#define _S 0x43
#define _T 0x54
#define _U 0xA9
#define _F 0xAA
#define _H 0x58
#define _C 0xE1
#define _CH 0xAB//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1063]"
#define _SH 0xAC//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1064]"
#define _SHT 0xE2//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1065]"
//#define _ERg //[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1100]" - ([ch1077][ch1088] -[ch1075][ch1086][ch1083][ch1103][ch1084][ch1086]) [ch1058][ch1072][ch1082][ch1098][ch1074] [ch1090][ch1080][ch1087] [ch1075][ch1083][ch1072][ch1074][ch1085][ch1072] [ch1073][ch1091][ch1082][ch1074][ch1072] [ch1085][ch1077] [ch1089][ch1077] [ch1080][ch1079][ch1087][ch1086][ch1083][ch1079][ch1074][ch1072]
#define _Y 0xAD //[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1066]"
#define _IU 0xB0//[ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1070]"
#define _Q 0xB1 // [ch1073][ch1091][ch1082][ch1074][ch1072] "[ch1071]"
#define _space 0x20 //[ch1058][ch1086][ch1074][ch1072] [ch1089][ch1077] [ch1103][ch1074][ch1103][ch1074][ch1072] [ch1087][ch1088][ch1072][ch1079][ch1077][ch1085] [ch1073][ch1083][ch1086][ch1082] [ch1082][ch1086][ch1081][ch1090][ch1086] [ch1080][ch1084][ch1080][ch1090][ch1080][ch1088][ch1072] [ch1076][ch1077][ch1081][ch1089][ch1090][ch1074][ch1080][ch1077][ch1090][ch1086] [ch1085][ch1072] SPACE [ch1073][ch1091][ch1090][ch1086][ch1085][ch1072]
// [ch1085][ch1072] [ch1082][ch1083][ch1072][ch1074][ch1080][ch1072][ch1090][ch1091][ch1088][ch1072][ch1090][ch1072]
#define countof(a) (sizeof(a) / sizeof(a[0]))//[ch1044][ch1077][ch1092][ch1080][ch1085][ch1080][ch1088][ch1072][ch1084][ch1077]/[ch1057][ch1098][ch1079][ch1076][ch1072][ch1074][ch1072][ch1084][ch1077] [ch1085][ch1086][ch1074][ch1072] [ch1092][ch1091][ch1085][ch1082][ch1094][ch1080][ch1103] [ch1089] [ch1080][ch1084][ch1077][ch1090][ch1086] "countof" [ch1082][ch1086][ch1103][ch1090][ch1086] [ch1086][ch1087][ch1088][ch1077][ch1076][ch1077][ch1083][ch1103],
//[ch1082][ch1086][ch1083][ch1082][ch1086] [ch1085][ch1072] [ch1073][ch1088][ch1086][ch1081] [ch1077][ch1083][ch1077][ch1084][ch1077][ch1085][ch1090][ch1072] [ch1089][ch1077] [ch1089][ch1098][ch1076][ch1098][ch1088][ch1078][ch1072][ch1090] [ch1074] [ch1088][ch1077][ch1076][ch1080][ch1094][ch1072]/[ch1084][ch1072][ch1090][ch1088][ch1080][ch1094][ch1072] [ch1088][ch1077][ch1076] "a" ([ch1090][ch1072][ch1082][ch1072] [ch1087][ch1088][ch1077][ch1076][ch1089][ch1090][ch1072][ch1074][ch1077][ch1085][ch1086] "[ch1072]" [ch1077] [ch1087][ch1088][ch1086][ch1089][ch1090][ch1086] [ch1096][ch1072][ch1073][ch1083][ch1086][ch1085][ch1085][ch1086] [ch1087][ch1088][ch1077][ch1076][ch1089][ch1090][ch1072][ch1074][ch1103][ch1085][ch1077],
//[ch1087][ch1086]-[ch1085][ch1072][ch1090][ch1072][ch1090][ch1098][ch1082] [ch1074] [ch1087][ch1086][ch1083][ch1077][ch1090][ch1086] "[ch1072]" [ch1097][ch1077] [ch1079][ch1072][ch1076][ch1072][ch1074][ch1072][ch1084][ch1077] [ch1085][ch1072][ch1080][ch1084][ch1077][ch1085][ch1086][ch1074][ch1072][ch1085][ch1080][ch1077] [ch1085][ch1072] [ch1088][ch1072][ch1079][ch1083][ch1080][ch1095][ch1085][ch1080] [ch1087][ch1088][ch1086][ch1084][ch1077][ch1085][ch1083][ch1080][ch1074][ch1080].
int val;
int encoder0PinA=18;
int encoder0PinB=19;
long encoder0Pos=0;
int encoder0PinALast =LOW;
int h=LOW;
int encoderButton=17;
void setup()
{
lcd.begin(16,2);
lcd.clear();
pinMode(encoder0PinA,INPUT);
digitalWrite(encoder0PinA,HIGH);
pinMode(encoder0PinB,INPUT);
digitalWrite(encoder0PinB,HIGH);
pinMode(encoderButton,INPUT);
digitalWrite(encoderButton,HIGH);
Serial.begin(9600);
}
void loop()
{
mylopp();
delay(100);
}
void mylopp()
{
byte FT=0;
float SetFaultTimeout_sec=0.000;
byte FTcrc=0;
lcd.clear();
char ZadAvarVr[]={_A,_v,_a,_r,'.',' ',_V,_r,_e,_m,_e,_z,_a,_d,_r,'.','\0'};
lcd.print(ZadAvarVr);
lcd.setCursor(11,1);
// lcd.print("[sec]");
while(digitalRead(encoderButton)==HIGH)
{
h=digitalRead(encoder0PinA);
if((encoder0PinALast==LOW) && (h == HIGH))
{
if (digitalRead(encoder0PinB)==HIGH)
{
encoder0Pos--;
encoder0Pos = constrain(encoder0Pos,0,65535);
FT=encoder0Pos;
SetFaultTimeout_sec=(encoder0Pos*(0.262));//from 0x0000 to 0xFFFF The result is in seconds
}
else
{
encoder0Pos++;
encoder0Pos = constrain(encoder0Pos,0,65535);//from 0x0000 to 0xFFFF
FT=encoder0Pos;
SetFaultTimeout_sec=(encoder0Pos*(0.262));//[ch1056][ch1077][ch1079][ch1091][ch1083][ch1090][ch1072][ch1090][ch1072] [ch1077] [ch1074] [ch1089][ch1077][ch1082][ch1091][ch1085][ch1076][ch1080]
}
if ( (SetFaultTimeout_sec>17170.17) || (SetFaultTimeout_sec<0) )//0.262sec*65535=17170.17 [ch1082][ch1086][ch1077][ch1090][ch1086] [ch1077] [ch1084][ch1072][ch1082][ch1089][ch1080][ch1084][ch1072][ch1083][ch1085][ch1086][ch1090][ch1086] [ch1079][ch1072][ch1076][ch1072][ch1085][ch1080][ch1077] [ch1079][ch1072] [ch1040][ch1074][ch1072][ch1088][ch1072][ch1080][ch1081][ch1085][ch1072] [ch1042][ch1088][ch1077][ch1084][ch1077][ch1079][ch1072][ch1076][ch1088][ch1098][ch1078][ch1082][ch1072]
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print("RangeFT_Error");
abort();
}
else
{
if((SetFaultTimeout_sec<=17170.17) || (SetFaultTimeout_sec>=10000))
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC) ;
}
else
{
if((SetFaultTimeout_sec<10000) && (SetFaultTimeout_sec>=1000))//4 [ch1094][ch1080][ch1092][ch1088][ch1077][ch1085][ch1086]
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC);
}
else
{
if((SetFaultTimeout_sec<1000) && (SetFaultTimeout_sec>=100))//3 [ch1094][ch1080][ch1092][ch1088][ch1077][ch1085][ch1086]
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC);
}
else
{
if((SetFaultTimeout_sec<100) && (SetFaultTimeout_sec>=10))//2 [ch1094][ch1080][ch1092][ch1088][ch1077][ch1085][ch1086]
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC);
}
else
{
if((SetFaultTimeout_sec<10) && (SetFaultTimeout_sec>=1))//1 [ch1094][ch1080][ch1092][ch1088][ch1077][ch1085][ch1086]
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC);
}
else
{
if((SetFaultTimeout_sec>=0) && (SetFaultTimeout_sec<1))
{
lcd.setCursor(0,1);
lcd.print(" ");//16
lcd.setCursor(0,1);
lcd.print(SetFaultTimeout_sec,DEC);
}
}
}
}
}
}
}
}
encoder0PinALast = h;
}//[ch1050][ch1088][ch1072][ch1081] [ch1085][ch1072] while
byte FTlowByte=lowByte(FT);
byte FThighByte=highByte(FT);
}// [ch1050][ch1088][ch1072][ch1081] [ch1085][ch1072] mylopp
Well I want to make this code to show on my LCD a number in x.xxx format alas whatever I try I still get this.
for "0" i get "0.0000000000"
when I increment(using the encoder turning it right) I expect to get
0.262 but I get "0.2619999884"
when I rotatate again I should get
0.524 but I get "0.5239999771"
0.786 i get "0.7860000133"
and so on
I want to get numbers like:
0.262
1.310
1.834
2.620
an so on so pls help :-/