#include<Wire.h>
#include <LiquidCrystal.h> //เรียกใช้ Library
LiquidCrystal lcd(12, 11, 4, 5, 6, 7);
#define btnRESET 1
#define btnONE 2
#define btnFIVE 8
#define btnTEN 9
#define LED 13
unsigned int coinONE = 0;
unsigned int coinFIVE = 0;
unsigned int coinTEN = 0;
unsigned int previouscoinONE = 0;
unsigned int previouscoinFIVE = 0;
unsigned int previouscoinTEN = 0;
unsigned int coinSUM = 0;
boolean stateONE = 0;
boolean stateFIVE = 0;
boolean stateTEN = 0;
void setup()
{
attachInterrupt(0,FIVE, FALLING);
attachInterrupt(1,TEN,FALLING);
pinMode(btnRESET,INPUT);
pinMode(btnONE,INPUT);
pinMode(btnFIVE,INPUT);
pinMode(btnTEN,INPUT);
pinMode(LED,OUTPUT);
lcd.begin(16, 2); //กำหนดการใช้คอลัมน์และแถวของ LCD
lcd.setCursor(0, 0);
lcd.print(" Count Coin ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(2,2);
lcd.print("System");
delay(1500);
lcd.clear();
Show();
}
void loop()
{
if((digitalRead(btnONE) == LOW)&&(stateONE ==0))
{
digitalWrite(LED,LOW);
stateONE = 1;
delay(500);
}
if(stateFIVE == 0)&&(stateTEN == 0))
{
coinONE++;
}
}
if(digitalRead(btnRESET) == LOW)
{
coinONE = 0;
coinFIVE = 0;
coinTEN = 0;
coin SUM = 0;
previouscoinONE = 0;
previouscoinFIVE = 0;
previouscoinTEN = 0;
stateONE = 0;
stateFIVE = 0;
lcd.setCursor(0, 0);
lcd.print(" Count coin ");
lcd.setCursor(0,2);
lcd.print(" Clear. ");
delay(1500);
lcd.clear();
Show();
}
if((coinONE != previouscoinONE)||(coinFIVE != previouscoinFIVE)||(coinTEN != previouscoinTEN))
{
Show();
previouscoinONE = coinONE;
previouscoinFIVE = coinFIVE;
previouscoinTEN = coinTEN;
}
}
void FIVE()
{
stateFIVE = 1;
if(stateONE == 0)
{
coinONE++;
}
if(stateONE == 1)
{
coinFIVE++;
}
}
void TEN()
{
stateTEN = 1;
if((stateONE == 1)&&(stateFIVE == 1))
{
coinTEN++:
coinFIVE--;
}
}
void Show()
{
coinSUM = ((coinONE1)+(coinFIVE5)+(coinTEN*10));
lcd.setCursor(0,0);
lcd.print(" 1= ");
if(coinONE < 1) {lcd.print("00");}
else if(coinONE <10) {lcd.print("0");}
else if (coinONE <100) {lcd.print("0");}
lcd.print(coinONE);
lcd.setCursor(0,8);
lcd.print(" 5= ");
if(coinFIVE < 1) {lcd.print("00");}
else if(coinFIVE <10) {lcd.print("0");}
else if (coinFIVE <100) {lcd.print("0");}
lcd.print(coinFIVE);
lcd.setCursor(1,1);
lcd.print("10 = ");
if(coinTEN < 1) {lcd.print("00");}
else if(coinTEN <10) {lcd.print("0");}
else if (coinTEN <100) {lcd.print("0");}
lcd.print(coinTEN);
stateONE = 0;
stateFIVE = 0;
stateTEN = 0;
}
Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Nes\Documents\Arduino\sketch_aug20c\sketch_aug20c.ino: In function 'void setup()':
sketch_aug20c:27: error: 'FIVE' was not declared in this scope
attachInterrupt(0,FIVE, FALLING);
^
sketch_aug20c:28: error: 'TEN' was not declared in this scope
attachInterrupt(1,TEN,FALLING);
^
sketch_aug20c:45: error: 'Show' was not declared in this scope
Show();
^
C:\Users\Nes\Documents\Arduino\sketch_aug20c\sketch_aug20c.ino: In function 'void loop()':
sketch_aug20c:56: error: expected identifier before '(' token
if(stateFIVE == 0)&&(stateTEN == 0))
^
C:\Users\Nes\Documents\Arduino\sketch_aug20c\sketch_aug20c.ino: At global scope:
sketch_aug20c:62: error: expected unqualified-id before 'if'
if(digitalRead(btnRESET) == LOW)
^
sketch_aug20c:82: error: expected unqualified-id before 'if'
if((coinONE != previouscoinONE)||(coinFIVE != previouscoinFIVE)||(coinTEN != previouscoinTEN))
^
sketch_aug20c:89: error: expected declaration before '}' token
}
^
Multiple libraries were found for "Wire.h"
Used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Not used: C:\Program Files (x86)\Arduino\libraries\Wire
exit status 1
'FIVE' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
So sad i can't Verify.