const int sw = 3;
int val;
void setup()
{
pinMode(sw, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
val = digitalRead(sw);
if (val == HIGH)//我的板子4*4是提昇電阻
//我要沒按是0V,有按是5v
digitalWrite(led, LOW);
else
digitalWrite(led, HIGH);
}
方法2:
const int led = 2;
const int sw = 3;
int val;
void setup()
{
pinMode(sw, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
val = digitalRead(sw);
if (val == LOW)//我的板子4*4是提昇電阻
//我要沒按是0V,有按是5v
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
}
方法3:
const int led = 2;
const int sw = 3;
int val;
void setup()
{
pinMode(sw, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
val = digitalRead(sw);
if (val != LOW)//我的板子4*4是提昇電阻,不等於
//我要沒按是0V,有按是5v
digitalWrite(led, LOW);
else
digitalWrite(led, HIGH);
}
const int sw = 3;
int val;
void setup()
{
pinMode(sw, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
val = digitalRead(sw);
if (val == LOW)//我的板子4*4是提昇電阻
//我要沒按是0V,有按是5v
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
}
方法3:
const int led = 2;
const int sw = 3;
int val;
void setup()
{
pinMode(sw, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
val = digitalRead(sw);
if (val != LOW)//我的板子4*4是提昇電阻,不等於
//我要沒按是0V,有按是5v
digitalWrite(led, LOW);
else
digitalWrite(led, HIGH);
}
沒有留言:
張貼留言