目次
Lチカ写真
![f:id:appdeappuappu:20200510095417j:plain タクトスイッチを押している写真](https://scombu.com/wp-content/uploads/2022/04/20200510095417.jpg)
回路図
![f:id:appdeappuappu:20200510093957p:plain fritzingでの回路図](https://scombu.com/wp-content/uploads/2022/04/20200510093957-757x1024.png)
コーディング
#define switchiButtonPin 13
#define ledPin 10
int buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchiButtonPin, INPUT_PULLUP); // Inputモードでプルアップ
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) { // ボタンが押されていたら、ピンの値はLOW
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
delay(50);
}
引用
こちらを参考にさせていただきました。↓
novicengineering.com
コメント