久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2784|回復: 1
打印 上一主題 下一主題
收起左側

定時開關計時器 當我用Arduino UNO 測試時,計時器工作但是開關計計數不工作

[復制鏈接]
跳轉到指定樓層
樓主
ID:118080 發表于 2016-5-8 02:17 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
這是小弟的代碼
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
int runTimer = 1;
int runFor = 50; // time in seconds
int buzzerPin = 13;
int relayPin=4;
int data = 0;

const int switchPin = 5;
int hits = 0;
int switchState = 0;
int prevSwitchState = 0;


const int switchPin1 = 6;
int hits1 = 0;
int switchState1 = 0;
int prevSwitchState1 = 0;


void setup() {
{

   pinMode(buzzerPin, OUTPUT);
   pinMode(relayPin,OUTPUT);
   lcd.begin(16, 0);
}
{
   lcd.begin(16, 2);
   pinMode(switchPin,INPUT);



  pinMode(switchPin1,INPUT);

}
}

void loop() {

   switchState = digitalRead(switchPin);

  if (switchState != prevSwitchState) {
    if (switchState == LOW) {
      hits = hits + 1;
      lcd.clear();
      lcd.setCursor(0, 1);
      lcd.print("Hits:");
      lcd.setCursor(7, 1);
      lcd.print(hits);
      lcd.setCursor(11, 1);
      lcd.print(hits1);
      delay(90);
    }
  }
   prevSwitchState = switchState;


   switchState1 = digitalRead(switchPin1);

  if (switchState1 != prevSwitchState1) {
    if (switchState1 == LOW) {
      hits1 = hits1 + 1;
      lcd.clear();
      lcd.setCursor(0, 1);
      lcd.print("Hits:");
      lcd.setCursor(11, 1);
      lcd.print(hits1);
      lcd.setCursor(7, 1);
      lcd.print(hits);
      delay(90);
    }
  }
  prevSwitchState1 = switchState1;

   if(runTimer == 1){
      digitalWrite(relayPin,LOW); // relay is OFF during countdown

      lcd.clear();
      lcd.print("TIMER=");

      lcd.setCursor(0, 1);
      lcd.print("Hits:");
      lcd.setCursor(7, 1);
      lcd.print(hits);
      lcd.setCursor(11, 1);
      lcd.print(hits1)
      //Start timer
      ;timer();
   }
   runTimer = 0;
   lcd.noDisplay();
   delay(250);
   for(int duration = 0; duration < 100; duration ++){
      digitalWrite(buzzerPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(buzzerPin, LOW);
      delayMicroseconds(500);
   }
   lcd.display();
   delay(250);
}

void timer() {
   for(int timer = runFor;timer > 0; --timer){
   if(timer >= 10) {
      lcd.setCursor(6,0);
   } else {   
      lcd.setCursor(6,0);
      lcd.print("0");
      lcd.setCursor(7,0);
   }
   lcd.print(timer);
   lcd.print(" SECOND!");
   delay(1000);
   }
   lcd.setCursor(1,1);
   lcd.clear();
   lcd.print(" TIMER OUT!");

      lcd.setCursor(0, 1);
      lcd.print("Hits:");
      lcd.setCursor(7, 1);
      lcd.print(hits);
      lcd.setCursor(11, 1);
      lcd.print(hits1);
}

當我用Arduino UNO 測試時,計時器工作但是開關計計數不工作。。請大神指點
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:118080 發表于 2016-5-8 02:19 | 只看該作者
具體功能是,倒計時50,然后在倒計時這段時間記錄兩個開關的按鍵次數。倒計時結束 停止開關計數。。。
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产激情在线看 | 97av在线| 欧美一区二区三区在线观看 | 免费观看一级特黄欧美大片 | 日韩在线观看一区 | 日本一区二区高清视频 | 99在线免费视频 | 久久精品国产精品青草 | 在线视频一区二区三区 | 精品国产乱码久久久久久1区2区 | 国产视频2021 | 亚洲欧美日韩精品久久亚洲区 | 亚洲国产精品日本 | 国产精品久久久久不卡 | 国产精品成av人在线视午夜片 | 国产精品一区二区视频 | 日韩久久久久久 | av在线成人| 日韩成人在线观看 | 精品视频国产 | av不卡一区| 播放一级黄色片 | 欧美日韩精品久久久免费观看 | 羞羞视频在线观免费观看 | 国产精品a久久久久 | 成人av在线播放 | 91欧美 | 免费观看一级毛片视频 | 一级黄色影片在线观看 | 涩涩视频在线看 | 午夜欧美一区二区三区在线播放 | 亚洲一区二区中文字幕 | 久久久久亚洲精品 | 成人自拍视频网站 | 亚洲免费人成在线视频观看 | 天天久久 | 国产精品久久国产精品久久 | 亚洲国产精品一区 | 激情小视频 | 久久成人一区 | 日韩中文字幕在线观看 |