作者sdsd65676 (翻桌ING)
看板ASM
标题[请益] Arduino程式请教
时间Tue Jan 16 07:22:38 2018
各位先进好,小弟是刚接触Arduino的新手
因为专题需求自己写了程式码,但是遇到了一些问题。
先附上我的程式码
int a = 3;
int b = 2;
int c = 4;
int d = 7;
int e = 8;
int f = 12;
void setup() {
// put your setup code here, to run once:
pinMode(a, INPUT); //钥匙开关;
pinMode(b, INPUT); //档位开关;
pinMode(c, INPUT); //距离感知器;
pinMode(d, INPUT); //静音开关;
pinMode(e, OUTPUT); //无声输出;
pinMode(f, OUTPUT); //有声输出;
if (digitalRead (a == HIGH), digitalRead(b == HIGH)
, digitalRead(d == HIGH)) //红火 P档 静音, 无声输出;
{
digitalWrite(e, HIGH);
delay(250);
digitalWrite(e, LOW);
delay(250);
}
if ( digitalRead (a == HIGH ), digitalRead(b == HIGH
, digitalRead(d == LOW)); //红火 P档 有声, 有声输出;
{
digitalWrite(f, HIGH);
delay(250);
digitalWrite(f, LOW);
delay(250);
loop;
}
if ( digitalRead ([code]
if ( digitalRead (a == LOW ), digitalRead (b == HIGH)
, digitalRead (d == HIGH)); //熄火 P档 静音, 无声输出5秒;
{
digitalWrite(e, HIGH);
delay(5000);
digitalWrite(e, LOW);
delay(500);
digitalWrite(e, HIGH);
delay(500);
digitalWrite(e, LOW);
delay(500);
digitalWrite(e, HIGH);
delay(500);
digitalWrite(e, LOW);
delay(500);
digitalWrite(e, HIGH);
delay(500);
digitalWrite(e, LOW);
delay(500);
digitalWrite(e, HIGH);
[code]
delay(500);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
}
if ( digitalRead (a == LOW ), digitalRead (b == HIGH )
, digitalRead (d == LOW )); //熄火 P档 有声, 有声输出5秒;
{
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
delay(5000);
digitalWrite(f, LOW);
delay(500);
digitalWrite(f, HIGH);
delay(500);
digitalWrite(f, LOW);
delay(500);
digitalWrite(f, HIGH);
delay(500);
digitalWrite(f, LOW);
delay(500);
digitalWrite(f, HIGH);
delay(500);
digitalWrite(f, LOW);
delay(500);
digitalWrite(f, HIGH);
delay(500);
digitalWrite(f, LOW);
}
if ( digitalRead (a == HIGH ), digitalRead (b == LOW ));
{
digitalWrite(e, LOW);
digitalWrite(f, LOW);
}
}
void loop() {
// put your main code here, to run repeatedly:
pinMode(LED_BUILTIN, HIGH);
delay(100);
pinMode(LED_BUILTIN, LOW);
delay(100);
目前遇到的问题是,前两段程式码(红火、P档、有无声输出)不会跑到
也有试过不同的写法,都会不作用就跳到第三段
使用的板子是 Uno R3
再次谢谢帮忙解决的朋友~
--
1F:推 byone1 :加油,我是氧气,你ez打得很不错08/26 10:49
2F:→ sdsd65676 :3Q08/26 10:50
3F:→ sdsd65676 :双排ING08/26 10:55
4F:→ kiki761119 :我主main ad 也可走top上08/26 11:34
5F:推 longkiss0618:加油 我是二氧化碳 你EZ不错08/26 11:42
6F:推 Asty1e :加油 我是甲烷 你ez打的很不错08/26 11:45
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 49.216.247.157
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/ASM/M.1516058571.A.939.html
7F:→ sdsd65676: 身家微薄,附上税前200P给解决的大师! 01/16 07:24
8F:→ cocoaswifty: 把上面的if逻辑判断放到loop()里面 01/16 10:36
9F:推 BrianCashman: if内所有语法与函式参数皆不正确,请修正看看 01/16 11:57
11F:推 full0513: Setup里不是都放基本设定而已吗,那麽大串的判断式应该 01/18 03:59
12F:→ full0513: 放在loop吧,才会重复执行 01/18 03:59