Lieber Besucher, herzlich willkommen bei: Automatenfreunde.de - Das Forum rund um Automaten. Falls dies dein erster Besuch auf dieser Seite ist, lies bitte die Hilfe durch. Dort wird dir die Bedienung dieser Seite näher erläutert. Darüber hinaus solltest du dich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutze das Registrierungsformular, um dich zu registrieren oder informiere dich ausführlich über den Registrierungsvorgang. Falls du dich bereits zu einem früheren Zeitpunkt registriert hast, kannst du dich hier anmelden.
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
/* * Uhrensetzgerät V1.2 * =================== * Copyright by: Riiko * Das Programm darf weder verkauft noch irgendwo ausserhalb * der Foren www.automatenfreunde.de oder www.geldspielfreunde.de veröffentlicht werden! * Nieder mit den Abzockern!!! */ #include <LiquidCrystal.h> LiquidCrystal lcd(8, 9, 4, 5, 6, 7); byte symA[8] = { B01010,B00000,B01110,B00001,B01111,B10001,B01111,}; byte symB[8] = { B00000,B00000,B00001,B00010,B10100,B01000,B00000,}; byte symC[8] = { B00100,B01110,B10101,B00100,B00100,B00100,B00000,}; byte symD[8] = { B00100,B00100,B00100,B10101,B01110,B00100,B00000,}; byte symE[8] = { B00000,B10000,B01000,B00100,B00010,B00001,B00000,}; byte symF[8] = { B01010,B00000,B01110,B00001,B01111,B10001,B01111,}; byte symG[8] = { B00100,B00110,B00101,B00101,B00100,B11100,B11100,}; byte symH[8] = { B00110,B00101,B00111,B00101,B11101,B11011,B00011,}; int day = 1; int month = 2; int year = 16; int hour = 12; int minute = 0; int speedset = 0; int curpos = 1; int counterA = 0; int counterB = 0; int KeypadPin = A0; int KeypadValue = 0; int keystate = 0; int lastkey =0; int mode = 0; void setup() { lcd.createChar(0, symA); lcd.createChar(1, symB); lcd.createChar(2, symC); lcd.createChar(3, symD); lcd.createChar(4, symE); lcd.createChar(5, symF); lcd.createChar(6, symG); lcd.createChar(7, symH); Serial.begin(4800, SERIAL_8N1); lcd.begin(16,2); lcd.print("<Alpha-Networks>"); lcd.setCursor(0,1); lcd.print("Uhrensetzger\5t"); delay(2500); lcd.setCursor(0,0); lcd.print("Seriennummer: "); lcd.setCursor(0,1); lcd.print("Selbstgebaut "); delay(2500); lcd.setCursor(0,0); lcd.print("TT.MM.JJ HH:MM"); lcd.setCursor(0,1); lcd.print(" ============== "); delay(1500); lcd.setCursor(0,0); lcd.print("01.02.16 12:00"); lcd.setCursor(0,1); lcd.print("\2\3"); lcd.write(126); lcd.print(" Tag"); } void changeday() { lcd.setCursor(0,1); lcd.print("\2\3"); lcd.write(126); lcd.print(" Tag"); if (keystate == 3) {day = day + 1; }; if (keystate == 4) {day = day - 1; }; if (day > 31) {day = 1; }; if (day < 1) {day = 31; }; lcd.setCursor(0,0); if (day < 10) {lcd.print("0");}; lcd.print(day); } void changemonth() { lcd.setCursor(0,1); lcd.print(" "); lcd.write(127); lcd.print("\2\3"); lcd.write(126); lcd.print(" Monat"); if (keystate == 3) {month = month + 1; }; if (keystate == 4) {month = month - 1; }; if (month > 12) {month = 1; }; if (month < 1) {month = 12; }; lcd.setCursor(3,0); if (month < 10) {lcd.print("0");}; lcd.print(month); } void changeyear() { lcd.setCursor(0,1); lcd.print(" "); lcd.write(127); lcd.print("\2\3"); lcd.write(126); lcd.print(" Jahr"); if (keystate == 3) {year = year + 1; }; if (keystate == 4) {year = year - 1; }; if (year > 99) {year = 0; }; if (year < 0) {year = 99; }; lcd.setCursor(6,0); if (year < 10) {lcd.print("0");}; lcd.print(year); } void changehour() { lcd.setCursor(0,1); lcd.print("Stunde "); lcd.write(127); lcd.print("\2\3"); lcd.write(126); lcd.print(" "); if (keystate == 3) {hour = hour + 1; }; if (keystate == 4) {hour = hour - 1; }; if (hour > 23) {hour = 0; }; if (hour < 0) {hour = 23; }; lcd.setCursor(11,0); if (hour < 10) {lcd.print("0");}; lcd.print(hour); } void changeminutes() { lcd.setCursor(0,1); lcd.print("Minute "); lcd.write(127); lcd.print("\2\3"); if (keystate == 3) {minute = minute + 1; }; if (keystate == 4) {minute = minute - 1; }; if (minute > 59) {minute = 0; }; if (minute < 0) {minute = 59; }; lcd.setCursor(14,0); if (minute < 10) {lcd.print("0");}; lcd.print(minute); } void valchange() { if (keystate == 5) { curpos = curpos +1; }; if (keystate == 2) { curpos = curpos -1; }; if (curpos <= 0) {curpos = 5;}; if (curpos >= 6) {curpos = 1;}; if (curpos <= 1 ) { changeday(); }; if (curpos == 2 ) { changemonth(); }; if (curpos == 3 ) { changeyear(); }; if (curpos == 4 ) { changehour(); }; if (curpos == 5 ) { changeminutes(); }; } void preparesend() { if (keystate == 5) { curpos = 2; lcd.setCursor(0,1); lcd.print(" JA [NEIN]"); }; if (keystate == 2) { curpos = 1; lcd.setCursor(0,1); lcd.print("[ JA ] NEIN "); }; } void loop() { KeypadValue = analogRead(KeypadPin); //lcd.setCursor(0,0);lcd.print(KeypadValue);lcd.print(" "); if ((KeypadValue >= 0) & (KeypadValue < 100)) { keystate = 5; }; if ((KeypadValue >= 80) & (KeypadValue < 200)) { keystate = 3; }; if ((KeypadValue >= 200) & (KeypadValue < 400)) { keystate = 4; }; if ((KeypadValue >= 400) & (KeypadValue < 600)) { keystate = 2; }; if ((KeypadValue >= 600) & (KeypadValue < 900)) { keystate = 1; }; if (KeypadValue >= 900) { keystate = 0; }; if (mode == 2) { curpos = curpos +1; counterB = counterB + 1; delay(100); if (curpos >= 5) {curpos = 1;}; if (curpos == 1) { lcd.setCursor(14,0); lcd.print("|"); }; if (curpos == 2) { lcd.setCursor(14,0); lcd.print("/"); }; if (curpos == 3) { lcd.setCursor(14,0); lcd.print("-"); }; if (curpos == 4) { lcd.setCursor(14,0); lcd.print("\4"); }; if (counterB == 8) { Serial.print("**ZEIT*:");delay(1); if (hour < 10) {Serial.print("0");delay(1);}; Serial.print(hour);delay(1); if (minute < 10) {Serial.print("0");delay(1);}; Serial.print(minute);delay(1); if (day < 10) {Serial.print("0");delay(1);}; Serial.print(day);delay(1); if (month < 10) {Serial.print("0");delay(1);}; Serial.print(month);delay(1); if (year < 10) {Serial.print("0");delay(1);}; Serial.print(year);delay(1); Serial.print("00");delay(1); Serial.print("00");delay(1); Serial.print("\r"); delay(50); lcd.setCursor(14,0); lcd.print("\1"); lcd.setCursor(0,1); lcd.print("Abgeschlossen!\6\7"); delay(2500); counterB = 0; keystate = 0; mode = 0; curpos = 1; lcd.setCursor(0,0); if (day < 10) {lcd.print("0");}; lcd.print(day); lcd.print("."); if (month < 10) {lcd.print("0");}; lcd.print(month); lcd.print("."); if (year < 10) {lcd.print("0");}; lcd.print(year); lcd.print(" "); if (hour < 10) {lcd.print("0");}; lcd.print(hour); lcd.print(":"); if (minute < 10) {lcd.print("0");}; lcd.print(minute); lcd.setCursor(0,1); lcd.print("\2\3"); lcd.write(126); lcd.print(" Tag"); }; }; if (keystate != lastkey) { lastkey = keystate; counterA = 0; speedset = 0; if (mode == 1) { if (keystate != 1) {preparesend();}; if ((keystate == 1)&& (curpos == 2)){ keystate = 0; mode = 0; curpos = 1; lcd.setCursor(0,0); if (day < 10) {lcd.print("0");}; lcd.print(day); lcd.print("."); if (month < 10) {lcd.print("0");}; lcd.print(month); lcd.print("."); if (year < 10) {lcd.print("0");}; lcd.print(year); lcd.print(" "); if (hour < 10) {lcd.print("0");}; lcd.print(hour); lcd.print(":"); if (minute < 10) {lcd.print("0");}; lcd.print(minute); lcd.setCursor(0,1); lcd.print("\2\3"); lcd.write(126); lcd.print(" Tag"); }; if ((keystate == 1)&& (curpos == 1)){ keystate = 0; mode = 2; curpos = 1; lcd.setCursor(0,0); lcd.print("Sende Daten...| "); lcd.setCursor(0,1); lcd.print(" "); }; }; if (mode == 0) { if (keystate != 1) {valchange();}; if (keystate == 1) { mode = 1; curpos = 2 ; lcd.setCursor(0,0); lcd.print("Daten senden? "); lcd.setCursor(0,1); lcd.print(" JA [NEIN]"); }; }; }; counterA = counterA + 1; if (keystate != 0) { if (counterA > 50) { if (speedset < 1) { counterA = 0; speedset = speedset + 1; valchange(); }; }; if (counterA > 10) { if ((speedset >= 1 ) && (speedset < 8)) { counterA = 0; speedset = speedset + 1; valchange(); }; }; if (counterA > 5) { if ((speedset >= 8) && (speedset < 16)) { counterA = 0; speedset = speedset + 1; valchange(); }; }; if (counterA > 1) { if (speedset >= 16){ counterA = 0; speedset = speedset + 1; valchange(); }; }; }; delay(20); } |