我們有一個原型,可以將大額賬單變成更小的賬單。我們使用一個帶鍵盤的Arduino微控制器,用戶應該按下鍵盤上的「0」按鈕以便機器開始一個事務。用戶可以輸入一個值來選擇他們的面值類型。例如,如果您在機器內插入100美元鈔票,用戶可以選擇是否將其作爲兩張50美元鈔票或五張20美元鈔票。使用C編程在Arduino微控制器上禁用鍵盤
我們的原型的問題是,當機器檢測到沒有剩餘的交易金額時,用戶仍然可以使用機器進行其他交易。在我們的編碼中有一個「bug」,如果你隨機按下所有的鍵。用戶可以按「0」開始交易。如果機器檢測到沒有錢用於其他交易,我們希望禁用鍵盤。
以下是代碼,如果機器檢測到沒有帳單。如果沒有賬單,它也會通知店主。
void SupChkU(){
sLBill5H = digitalRead(LBill5H);
if (sLBill5H == HIGH){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("500 Bills is empty ");
if (SLvlBill5H == false){
SLvlBill5H = true;
textForSMS = "500 Bills is empty, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
sLBill1H = digitalRead(LBill1H);
if (sLBill1H == HIGH){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("100 Bills is empty ");
if (SLvlBill1H == false){
SLvlBill1H = true;
textForSMS = "100 Bills is empty, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
sLBill50 = digitalRead(LBill50);
if (sLBill50 == HIGH){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("50 Bills is empty ");
if (SLvlBill50 == false){
SLvlBill50 = true;
textForSMS = "50 Bills is empty, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
if (CntB5H < 10){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("PhP 500 Bills Low Level");
if (SLvlBill5H == false){
SLvlBill5H = true;
textForSMS = " Low Level on PhP 500 Bills, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
if (CntB1H < 10){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("PhP 100 Bills Low Level");
if (SLvlBill1H == false){
SLvlBill1H = true;
textForSMS = " Low Level on PhP 100 Bills, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
if (CntB50 < 10){
lcd.setCursor(0, 0);
lcd.print("Low in resources");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
delay(100);
Serial.println("PhP 50 Bills Low Level");
if (SLvlBill50 == false){
SLvlBill50 = true;
textForSMS = " Low Level on PhP 50 Bills, please refill ";
sendSMS(textForSMS);
}
readkeyboard();
if (keypressed == 11){
RefillS();
}
}
sLCoin1 = digitalRead(LCoin1);
if (sLCoin1 == HIGH){
LvlC1 = true;
lcd.setCursor(0, 0);
lcd.print("Low for 1 Peso ");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
Serial.println(" Low Level for 1 Peso Bin ");
delay(1000);
if (SLvlC1 == false){
SLvlC1 = true;
textForSMS = " Low Level for 1 Peso Bin ";
sendSMS(textForSMS);
}
}
if (sLCoin1 == LOW){
SLvlC1 = false;
}
sLCoin5 = digitalRead(LCoin5);
if (sLCoin5 == HIGH){
LvlC5 = true;
lcd.setCursor(0, 0);
lcd.print("Low for 5 Peso ");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
Serial.println(" Low Level for 5 Peso Bin ");
delay(1000);
if (SLvlC5 == false){
SLvlC5 = true;
textForSMS = " Low Level for 5 Peso Bin ";
sendSMS(textForSMS);
}
}
if (sLCoin5 == LOW){
SLvlC5 = false;
}
sLCoin10 = digitalRead(LCoin10);
if (sLCoin10 == HIGH){
LvlC10 = true;
lcd.setCursor(0, 0);
lcd.print("Low for 10 Peso ");
lcd.setCursor(0, 1);
lcd.print("Please see owner");
Serial.println(" Low Level for 10 Peso Bin ");
delay(1000);
if (SLvlC10 == false){
SLvlC10 = true;
textForSMS = " Low Level for 10 Peso Bin ";
sendSMS(textForSMS);
}
}
if (sLCoin10 == LOW){
SLvlC10 = false;
}
}
好帖子。但你的問題在哪裏? – Farside
這不是C!一般來說Arduino不是C. – Olaf