Axiash
Newbie level 1
Me and my classmates are doing our school project using PIC16f84A and a coin acceptor. The hardware is working fine and the components are already configured. The problem is with the code that we're using. The coin acceptor will accept a coin which corresponds into a timer(Ex. 1 coin = 1 minute timer, 5$ dollar coin = 5 minute timer). Here is a sample code of our C program
The DELAYMINUTE act as our timer and we already tried it in simulation(using MPBLAB X IDE). I would like to ask how can we be sure that pulse from the coin acceptor goes into variable count(which is used for switch case). Thank You!
Code C - [expand] 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 unsigned char count = 0; unsigned char prevValue = LO; while(1) { switch (count){ case 3: PORTB=0x01; // asm ("Nop"); DELAYtenMinute(); count = 0x00; PORTB = 0x00; break; case 2: PORTB=0x01; DELAYfiveMinute(); count = 0x00; PORTB = 0x00; break; case 1: PORTB=0x01; DELAYoneMinute(); count = 0x00; PORTB = 0x00; break;
The DELAYMINUTE act as our timer and we already tried it in simulation(using MPBLAB X IDE). I would like to ask how can we be sure that pulse from the coin acceptor goes into variable count(which is used for switch case). Thank You!
Last edited by a moderator: