各位先进好,小弟是刚接触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
再次谢谢帮忙解决的朋友~