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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

定時開關計數器

[復制鏈接]
跳轉到指定樓層
樓主
ID:118080 發表于 2016-5-8 06:07 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
400黑幣
這是小弟的代碼
#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空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

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

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 成人在线一级片 | www久久爱| 欧美成人一级 | 成人一级片在线观看 | 久草新在线| 福利久久 | 国产不卡在线 | 日本国产精品视频 | 国产一区二区三区色淫影院 | 国产在线观看一区二区 | 天天操 夜夜操 | 国产成人精品久久 | 一区二区三区视频在线观看 | 激情久久久久 | 美女一区二区在线观看 | 国产高清免费 | 久久久久久久久久久一区二区 | 亚洲免费一区二区 | 亚洲欧美日韩一区二区 | 欧美日韩中文在线 | 国产毛片视频 | 亚洲欧美日韩一区二区 | 亚洲国产aⅴ成人精品无吗 国产精品永久在线观看 | 日韩中文字幕视频 | 久久国产精品亚洲 | 免费午夜视频在线观看 | 久久com| 一区二区国产精品 | 在线成人免费视频 | 欧美一区二 | 成人精品鲁一区一区二区 | 秋霞在线一区 | 日韩国产精品一区二区三区 | 日韩欧美综合在线视频 | 亚洲情侣视频 | 精品1区 | 亚洲在线视频 | 精品欧美一区二区精品久久久 | 国产成年人视频 | 国产探花在线精品一区二区 | av在线电影网 |