gpt4 book ai didi

c - 使用 C 编程禁用 arduino 微 Controller 上的键盘

转载 作者:行者123 更新时间:2023-11-30 19:40:08 25 4
gpt4 key购买 nike

我们有一个原型(prototype),可以将大钞票变成小钞票。我们使用的是带有键盘的arduino微 Controller ,用户应该按下键盘上的“0”按钮以便机器开始交易。用户可以输入一个值来选择其面额类型。例如,如果您将一张 100 美元的钞票插入机器中,用户可以选择是否要将其作为两张 50 美元的钞票或五张 20 美元的钞票。

我们原型(prototype)的问题是,当机器检测到一笔交易没有钱了时,用户仍然可以使用机器进行另一笔交易。如果您随机按下所有键,我们的编码中存在一个“错误”。用户可以按“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;
}
}

最佳答案

如果键盘连接在 SPI(MISO、MOSI、SCK,...)( https://de.wikipedia.org/wiki/Serial_Peripheral_Interface )上,您可以通过禁用接口(interface)来禁用它:

1) 将 PRR(节能寄存器)中的 PRSPI (?) 位设置为“1”

2) 取消设置(设置“0”)SPCR 寄存器(?)(SPI 控制寄存器)中的 SPE 位(SPI 启用)

请参阅处理器的数据表,也许寄存器和位命名有所不同

如果键盘连接在 UART 上,同样的方法(禁用接口(interface))也适用,...

关于c - 使用 C 编程禁用 arduino 微 Controller 上的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35815024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com