Components and supplies
DC Motor 6V include Wheel
Relay (generic)
Push Button
Arduino UNO
Sensor Shield
LED (generic)
Power Supply 6V for DC motor
Distance interupter (infrared/optocoupler) sensor, used for coin sensor number 2
Infrared (reflective) or line follower sensor, used for product detection
Proximity (electromagnetic) sensor, used for coin sensor number 1
LCD (Nokia 5110 LCD)
Apps and platforms
Arduino IDE
Solidworks
Project description
Code
Source code for Snacks Vending Machine
arduino
This is source code i used for this vending machine project
1const byte SIAP = 0; 2const byte KOIN_MASUK1 = 1; 3const byte KOIN_MASUK2 = 2; 4const byte KOIN_MASUK3 = 3; 5const byte KOIN_MASUK4 = 4; 6const byte KOIN_MASUK5 = 5; 7const byte KOIN_MASUK6 = 6; 8const byte KOIN_MASUK7 = 7; 9const byte SALDO_500 = 8; 10const byte SALDO_500500 = 9; 11const byte SALDO_500500500 = 10; 12const byte SALDO_500500500500 = 11; 13const byte SALDO_5005005001000 = 12; 14const byte SALDO_5001000 = 13; 15const byte SALDO_5001000500 = 14; 16const byte SALDO_50010001000 = 15; 17const byte SALDO_5005001000 = 16; 18const byte SALDO_1000 = 17; 19const byte SALDO_10001000 = 18; 20const byte SALDO_1000500 = 19; 21const byte SALDO_1000500500 = 20; 22const byte SALDO_10005001000 = 21; 23const byte KOIN_KELUAR = 22; 24byte state = SIAP; 25const float jeda_waktu = 876; 26unsigned long time1; 27unsigned long time2; 28unsigned long time3; 29unsigned long time4; 30unsigned long time5; 31unsigned long time6; 32unsigned long time7; 33 34#define PIN_SCE 7 35#define PIN_RESET 6 36#define PIN_DC 5 37#define PIN_SDIN 4 38#define PIN_SCLK 3 39#define LCD_C LOW 40#define LCD_D HIGH 41#define LCD_X 84 42#define LCD_Y 48 43 44static const byte ASCII[][5] = 45{ 46 {0x00, 0x00, 0x00, 0x00, 0x00} // 20 47 , {0x00, 0x00, 0x5f, 0x00, 0x00} // 21 ! 48 , {0x00, 0x07, 0x00, 0x07, 0x00} // 22 " 49 , {0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 # 50 , {0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $ 51 , {0x23, 0x13, 0x08, 0x64, 0x62} // 25 % 52 , {0x36, 0x49, 0x55, 0x22, 0x50} // 26 & 53 , {0x00, 0x05, 0x03, 0x00, 0x00} // 27 ' 54 , {0x00, 0x1c, 0x22, 0x41, 0x00} // 28 ( 55 , {0x00, 0x41, 0x22, 0x1c, 0x00} // 29 ) 56 , {0x14, 0x08, 0x3e, 0x08, 0x14} // 2a * 57 , {0x08, 0x08, 0x3e, 0x08, 0x08} // 2b + 58 , {0x00, 0x50, 0x30, 0x00, 0x00} // 2c , 59 , {0x08, 0x08, 0x08, 0x08, 0x08} // 2d - 60 , {0x00, 0x60, 0x60, 0x00, 0x00} // 2e . 61 , {0x20, 0x10, 0x08, 0x04, 0x02} // 2f / 62 , {0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0 63 , {0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1 64 , {0x42, 0x61, 0x51, 0x49, 0x46} // 32 2 65 , {0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3 66 , {0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4 67 , {0x27, 0x45, 0x45, 0x45, 0x39} // 35 5 68 , {0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6 69 , {0x01, 0x71, 0x09, 0x05, 0x03} // 37 7 70 , {0x36, 0x49, 0x49, 0x49, 0x36} // 38 8 71 , {0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9 72 , {0x00, 0x36, 0x36, 0x00, 0x00} // 3a : 73 , {0x00, 0x56, 0x36, 0x00, 0x00} // 3b ; 74 , {0x08, 0x14, 0x22, 0x41, 0x00} // 3c < 75 , {0x14, 0x14, 0x14, 0x14, 0x14} // 3d = 76 , {0x00, 0x41, 0x22, 0x14, 0x08} // 3e > 77 , {0x02, 0x01, 0x51, 0x09, 0x06} // 3f ? 78 , {0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @ 79 , {0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A 80 , {0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B 81 , {0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C 82 , {0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D 83 , {0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E 84 , {0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F 85 , {0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G 86 , {0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H 87 , {0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I 88 , {0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J 89 , {0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K 90 , {0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L 91 , {0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M 92 , {0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N 93 , {0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O 94 , {0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P 95 , {0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q 96 , {0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R 97 , {0x46, 0x49, 0x49, 0x49, 0x31} // 53 S 98 , {0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T 99 , {0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U 100 , {0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V 101 , {0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W 102 , {0x63, 0x14, 0x08, 0x14, 0x63} // 58 X 103 , {0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y 104 , {0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z 105 , {0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [ 106 , {0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥ 107 , {0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ] 108 , {0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^ 109 , {0x40, 0x40, 0x40, 0x40, 0x40} // 5f _ 110 , {0x00, 0x01, 0x02, 0x04, 0x00} // 60 ` 111 , {0x20, 0x54, 0x54, 0x54, 0x78} // 61 a 112 , {0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b 113 , {0x38, 0x44, 0x44, 0x44, 0x20} // 63 c 114 , {0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d 115 , {0x38, 0x54, 0x54, 0x54, 0x18} // 65 e 116 , {0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f 117 , {0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g 118 , {0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h 119 , {0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i 120 , {0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j 121 , {0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k 122 , {0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l 123 , {0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m 124 , {0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n 125 , {0x38, 0x44, 0x44, 0x44, 0x38} // 6f o 126 , {0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p 127 , {0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q 128 , {0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r 129 , {0x48, 0x54, 0x54, 0x54, 0x20} // 73 s 130 , {0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t 131 , {0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u 132 , {0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v 133 , {0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w 134 , {0x44, 0x28, 0x10, 0x28, 0x44} // 78 x 135 , {0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y 136 , {0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z 137 , {0x00, 0x08, 0x36, 0x41, 0x00} // 7b { 138 , {0x00, 0x00, 0x7f, 0x00, 0x00} // 7c | 139 , {0x00, 0x41, 0x36, 0x08, 0x00} // 7d } 140 , {0x10, 0x08, 0x08, 0x10, 0x08} // 7e � 141 , {0x78, 0x46, 0x41, 0x46, 0x78} // 7f → 142}; 143 144void LcdWrite(byte dc, byte data) 145{ 146 digitalWrite(PIN_DC, dc); 147 digitalWrite(PIN_SCE, LOW); 148 shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data); 149 digitalWrite(PIN_SCE, HIGH); 150} 151 152void LcdCharacter(char character) 153{ 154 LcdWrite(LCD_D, 0x00); 155 for (int index = 0; index < 5; index++) 156 { 157 LcdWrite(LCD_D, ASCII[character - 0x20][index]); 158 } 159 LcdWrite(LCD_D, 0x00); 160} 161 162void LcdClear(void) 163{ 164 for (int index = 0; index < LCD_X * LCD_Y / 8; index++) 165 { 166 LcdWrite(LCD_D, 0x00); 167 } 168} 169 170void LcdInitialise(void) 171{ 172 pinMode(PIN_SCE, OUTPUT); 173 pinMode(PIN_RESET, OUTPUT); 174 pinMode(PIN_DC, OUTPUT); 175 pinMode(PIN_SDIN, OUTPUT); 176 pinMode(PIN_SCLK, OUTPUT); 177 digitalWrite(PIN_RESET, LOW); 178 digitalWrite(PIN_RESET, HIGH); 179 LcdWrite(LCD_C, 0x21 ); 180 LcdWrite(LCD_C, 0xB1 ); 181 LcdWrite(LCD_C, 0x04 ); 182 LcdWrite(LCD_C, 0x14 ); 183 LcdWrite(LCD_C, 0x20 ); 184 LcdWrite(LCD_C, 0x0C ); 185} 186 187void LcdString(char *characters) 188{ 189 while (*characters) 190 { 191 LcdCharacter(*characters++); 192 } 193} 194 195void setup() { 196 //enable output on the digital pins 197 pinMode( 11, INPUT); 198 pinMode( 12, INPUT); 199 pinMode( 14, INPUT); 200 pinMode( 15, INPUT); 201 pinMode( 16, INPUT); 202 pinMode( 17, INPUT); 203 pinMode( 18, INPUT); 204 pinMode( 19, INPUT); 205 pinMode( 13 , OUTPUT); 206 pinMode( 8 , OUTPUT); 207 pinMode( 9 , OUTPUT); 208 pinMode( 10 , OUTPUT); 209 pinMode( 2 , OUTPUT); 210 digitalWrite(8, HIGH); 211 digitalWrite(9, HIGH); 212 digitalWrite(10, HIGH); 213 digitalWrite(13, LOW); 214 Serial.begin(9600); 215 Serial.println("=> Siap"); 216 LcdInitialise(); 217 LcdClear(); 218 LcdString(" Masukkan Koin Rp500 atau Koin Rp1000 @ Rp2000"); 219 delay(500); 220} 221 222void loop() { 223 int x = analogRead(14); 224 if (state == SIAP) { 225 if (x >= 33) { 226 state = KOIN_MASUK1; 227 time1 = millis(); 228 tone(2, 4200, 40); 229 Serial.println("snsr1,"); 230 Serial.println("start wkt"); 231 } 232 } 233 else if ((state == KOIN_MASUK1) && (!(digitalRead(13)))) { 234 if ((digitalRead(12)) && (state == KOIN_MASUK1)) { 235 unsigned long diff1 = (millis() - time1); 236 Serial.println("snsr2,"); 237 Serial.println("stop wkt"); 238 Serial.print("jeda wkt: "); 239 Serial.print(diff1); 240 Serial.println(" ms"); 241 if (diff1 > jeda_waktu) { 242 state = SALDO_1000; 243 LcdInitialise(); 244 LcdClear(); 245 LcdString(" diterima Saldo=Rp1000 Tambah Koin Koin Rp1000"); 246 digitalWrite (13, HIGH); 247 Serial.println("koin=Rp 1000, Saldo: Rp1000"); 248 tone(2, 4200, 299); 249 } 250 else if (diff1 < jeda_waktu) { 251 state = SALDO_500; 252 digitalWrite (13, HIGH); 253 LcdInitialise(); 254 LcdClear(); 255 LcdString(" diterima Saldo= Rp500 Tambah Koin Koin Rp500"); 256 Serial.println("koin=Rp 500, Saldo: Rp500"); 257 tone(2, 4200, 299); 258 } 259 } 260 } 261 262 if (state == SALDO_500) { 263 if (x >= 33) { 264 state = KOIN_MASUK2; 265 time2 = millis(); 266 tone(2, 4200, 40); 267 Serial.println("snsr1,"); 268 Serial.println("start wkt"); 269 } 270 } 271 else if ((state == KOIN_MASUK2) && ((digitalRead(13)))) { 272 if ((digitalRead(12)) && (state == KOIN_MASUK2)) { 273 unsigned long diff2 = (millis() - time2); 274 Serial.println("snsr2,"); 275 Serial.println("stop wkt"); 276 Serial.print("jeda wkt: "); 277 Serial.print(diff2); 278 Serial.println(" ms"); 279 if (diff2 > jeda_waktu) { 280 state = SALDO_5001000; 281 LcdInitialise(); 282 LcdClear(); 283 LcdString(" diterima Saldo=Rp1500 Tambah Koin Koin Rp1000"); 284 tone(2, 4200, 299); 285 Serial.println("koin=Rp 1000, Saldo: Rp1500"); 286 } 287 else if (diff2 < jeda_waktu) { 288 state = SALDO_500500; 289 LcdInitialise(); 290 LcdClear(); 291 LcdString(" diterima Saldo=Rp1000 Tambah Koin Koin Rp500"); 292 tone(2, 4200, 299); 293 Serial.println("koin=Rp 500, Saldo: Rp1000"); 294 } 295 } 296 } 297 298 if (state == SALDO_500500) { 299 if (x >= 33) { 300 state = KOIN_MASUK3; 301 time3 = millis(); 302 tone(2, 4200, 40); 303 Serial.println("snsr1,"); 304 Serial.println("start wkt"); 305 } 306 } 307 else if ((state == KOIN_MASUK3) && ((digitalRead(13)))) { 308 if ((digitalRead(12)) && (state == KOIN_MASUK3)) { 309 unsigned long diff3 = (millis() - time3); 310 Serial.println("snsr2,"); 311 Serial.println("stop wkt"); 312 Serial.print("jeda wkt: "); 313 Serial.print(diff3); 314 Serial.println(" ms"); 315 if (diff3 > jeda_waktu) { 316 state = SALDO_5005001000; 317 LcdInitialise(); 318 LcdClear(); 319 LcdString(" diterima Saldo=Rp2000 Pilih Produk Koin Rp1000"); 320 Serial.println("koin=Rp 1000, Saldo: Rp2000"); 321 tone(2, 4200, 799); 322 } 323 else if (diff3 < jeda_waktu) { 324 state = SALDO_500500500; 325 LcdInitialise(); 326 LcdClear(); 327 LcdString(" diterima Saldo=Rp1500 Tambah Koin Koin Rp500"); 328 Serial.println("koin=Rp 500, Saldo: Rp1500"); 329 tone(2, 4200, 299); 330 } 331 } 332 } 333 334 if (state == SALDO_500500500) { 335 if (x >= 33) { 336 state = KOIN_MASUK4; 337 time4 = millis(); 338 tone(2, 4200, 40); 339 Serial.println("snsr1,"); 340 Serial.println("start wkt"); 341 } 342 } 343 else if ((state == KOIN_MASUK4) && ((digitalRead(13)))) { 344 if ((digitalRead(12)) && (state == KOIN_MASUK4)) { 345 unsigned long diff4 = (millis() - time4); 346 Serial.println("snsr2,"); 347 Serial.println("stop wkt"); 348 Serial.print("jeda wkt: "); 349 Serial.print(diff4); 350 Serial.println(" ms"); 351 if (diff4 > jeda_waktu) { 352 state = SALDO_5005005001000; 353 LcdInitialise(); 354 LcdClear(); 355 LcdString(" diterima Saldo=Rp2500 Pilih Produk Koin Rp1000"); 356 Serial.println("koin=Rp 1000, Saldo: Rp2500"); 357 tone(2, 4200, 799); 358 } 359 else if (diff4 < jeda_waktu) { 360 state = SALDO_500500500500; 361 LcdInitialise(); 362 LcdClear(); 363 LcdString(" diterima Saldo=Rp2000 Pilih Produk Koin Rp500"); 364 Serial.println("koin=Rp 500, Saldo: Rp2000"); 365 tone(2, 4200, 799); 366 } 367 } 368 } 369 370if (state == SALDO_5001000) { 371 if (x >= 33) { 372 state = KOIN_MASUK5; 373 time5 = millis(); 374 tone(2, 4200, 40); 375 Serial.println("snsr1,"); 376 Serial.println("start wkt"); 377 } 378 } 379 else if ((state == KOIN_MASUK5) && ((digitalRead(13)))) { 380 if ((digitalRead(12)) && (state == KOIN_MASUK5)) { 381 unsigned long diff5 = (millis() - time5); 382 Serial.println("snsr2,"); 383 Serial.println("stop wkt"); 384 Serial.print("jeda wkt: "); 385 Serial.print(diff5); 386 Serial.println(" ms"); 387 if (diff5 > jeda_waktu) { 388 state = SALDO_50010001000; 389 LcdInitialise(); 390 LcdClear(); 391 LcdString(" diterima Saldo=Rp2500 Pilih Produk Koin Rp1000"); 392 Serial.println("koin=Rp 1000, Saldo: Rp2500"); 393 tone(2, 4200, 799); 394 } 395 else if (diff5 < jeda_waktu) { 396 state = SALDO_5001000500; 397 LcdInitialise(); 398 LcdClear(); 399 LcdString(" diterima Saldo=Rp2000 Pilih Produk Koin Rp500"); 400 Serial.println("koin=Rp 500, Saldo: Rp2000"); 401 tone(2, 4200, 799); 402 } 403 } 404 } 405 406 if (state == SALDO_1000) { 407 if (x >= 33) { 408 state = KOIN_MASUK6; 409 time6 = millis(); 410 tone(2, 4200, 40); 411 Serial.println("snsr1,"); 412 Serial.println("start wkt"); 413 } 414 } 415 else if ((state == KOIN_MASUK6) && ((digitalRead(13)))) { 416 if ((digitalRead(12)) && (state == KOIN_MASUK6)) { 417 unsigned long diff6 = (millis() - time6); 418 Serial.println("snsr2,"); 419 Serial.println("stop wkt"); 420 Serial.print("jeda wkt: "); 421 Serial.print(diff6); 422 Serial.println(" ms"); 423 if (diff6 > jeda_waktu) { 424 state = SALDO_10001000; 425 LcdInitialise(); 426 LcdClear(); 427 LcdString(" diterima Saldo=Rp2000 Pilih Produk Koin Rp1000"); 428 Serial.println("koin=Rp 1000, Saldo: Rp2000"); 429 tone(2, 4200, 799); 430 } 431 else if (diff6 < jeda_waktu) { 432 state = SALDO_1000500; 433 LcdInitialise(); 434 LcdClear(); 435 LcdString(" diterima Saldo=Rp1500 Tambah Koin Koin Rp500"); 436 Serial.println("koin=Rp 500, Saldo: Rp1500"); 437 tone(2, 4200, 299); 438 } 439 } 440 } 441 442 if (state == SALDO_1000500) { 443 if (x >= 33) { 444 state = KOIN_MASUK7; 445 time7 = millis(); 446 tone(2, 4200, 40); 447 Serial.println("snsr1,"); 448 Serial.println("start wkt"); 449 } 450 } 451 else if ((state == KOIN_MASUK7) && ((digitalRead(13)))) { 452 if ((digitalRead(12)) && (state == KOIN_MASUK7)) { 453 unsigned long diff7 = (millis() - time7); 454 Serial.println("snsr2,"); 455 Serial.println("stop wkt"); 456 Serial.print("jeda wkt: "); 457 Serial.print(diff7); 458 Serial.println(" ms"); 459 if (diff7 > jeda_waktu) { 460 state = SALDO_10005001000; 461 LcdInitialise(); 462 LcdClear(); 463 LcdString(" diterima Saldo=Rp2500 Pilih Produk Koin Rp1000"); 464 Serial.println("koin=Rp 1000, Saldo: Rp2500"); 465 tone(2, 4200, 799); 466 } 467 else if (diff7 < jeda_waktu) { 468 state = SALDO_1000500500; 469 LcdInitialise(); 470 LcdClear(); 471 LcdString(" diterima Saldo=Rp2000 Pilih Produk Koin Rp500"); 472 Serial.println("koin=Rp 500, Saldo: Rp2000"); 473 tone(2, 4200, 799); 474 } 475 } 476 } 477 478 else if ((state == SALDO_500500500500)||(state == SALDO_5005005001000)||(state == SALDO_5001000500)||(state == SALDO_50010001000)||(state == SALDO_5005001000)||(state == SALDO_10001000)||(state == SALDO_1000500500)||(state == SALDO_10005001000)) { 479 if (((( digitalRead(13) && ( ( digitalRead(9) ) && ( digitalRead(10) ) ) ) && digitalRead(17) )) && ((digitalRead(8)))) { 480 LcdInitialise(); 481 LcdClear(); 482 LcdString(" Mohon Menunggu"); 483 Serial.println("pb1"); 484 tone(2, 4200, 200); 485 delay( 2500 ); 486 digitalWrite( 8 , LOW ); 487 Serial.println("motor1"); 488 } 489 else { 490 if ( (!(digitalRead(8)) && (!(digitalRead(11)) ))) { 491 digitalWrite( 8 , HIGH ); 492 LcdInitialise(); 493 LcdClear(); 494 LcdString(" Terima Kasih"); 495 tone(2, 4200, 100); 496 delay( 150 ); 497 tone(2, 4200, 100); 498 Serial.println("produk1 jatuh"); 499 delay( 4000 ); 500 digitalWrite( 13 , LOW ); 501 state = KOIN_KELUAR; 502 } 503 else { 504 } 505 } 506 if (((( ( digitalRead(13) && ( ( digitalRead(8) ) && ( digitalRead(10) ) ) ) && digitalRead(18) )) && ((digitalRead(9))))) { 507 LcdInitialise(); 508 LcdClear(); 509 LcdString(" Mohon Menunggu"); 510 Serial.println("pb2"); 511 tone(2, 4200, 200); 512 delay( 2500 ); 513 digitalWrite( 9 , LOW ); 514 Serial.println("motor2"); 515 } 516 else { 517 if ( (!(digitalRead(9)) && (!(digitalRead(15)) ))) { 518 digitalWrite( 9 , HIGH ); 519 LcdInitialise(); 520 LcdClear(); 521 LcdString(" Terima Kasih"); 522 tone(2, 4200, 100); 523 delay( 150 ); 524 tone(2, 4200, 100); 525 Serial.println("produk2 jatuh"); 526 delay( 4000 ); 527 digitalWrite( 13 , LOW ); 528 state = KOIN_KELUAR; 529 } 530 else { 531 } 532 } 533 if (((( ( digitalRead(13) && ( ( digitalRead(8) ) && ( digitalRead(9) ) ) ) && digitalRead(19) )) && ((digitalRead(10))))) { 534 LcdInitialise(); 535 LcdClear(); 536 LcdString(" Mohon Menunggu"); 537 Serial.println("pb3"); 538 tone(2, 4200, 200); 539 delay( 2500 ); 540 digitalWrite( 10 , LOW ); 541 Serial.println("motor3"); 542 } 543 else { 544 if ( (!(digitalRead(10)) && (!(digitalRead(16)) ))) { 545 digitalWrite( 10 , HIGH ); 546 LcdInitialise(); 547 LcdClear(); 548 LcdString(" Terima Kasih"); 549 tone(2, 4200, 100); 550 delay( 150 ); 551 tone(2, 4200, 100); 552 Serial.println("produk3 jatuh"); 553 delay( 4000 ); 554 digitalWrite( 13 , LOW ); 555 state = KOIN_KELUAR; 556 } 557 else { 558 } 559 } 560 } 561 else if ((state == KOIN_KELUAR)) { 562 if (((x <= 33) && !digitalRead(12)) && (!digitalRead(13))) { 563 state = SIAP; 564 LcdInitialise(); 565 LcdClear(); 566 LcdString(" Masukkan Koin Rp500 atau Koin Rp1000 @ Rp2000"); 567 Serial.println("=> Siap"); 568 } 569 } 570}
Documentation
Printscreen of Solidworks model for this Snacks Vending Machine
This is printscreen of my solidworks 3d model for this project.
Printscreen of Solidworks model for this Snacks Vending Machine
Printscreen of Solidworks model for this Snacks Vending Machine
This is printscreen of my solidworks 3d model for this project.
Printscreen of Solidworks model for this Snacks Vending Machine
Comments
Only logged in users can leave comments