Last active
October 22, 2023 05:44
-
-
Save a3510377/891ba128068c26e6f3455750b0e8d886 to your computer and use it in GitHub Desktop.
發送紅外線訊號(使用 IRremote v4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <IRremote.hpp> | |
const uint8_t address = 0x01; | |
unsigned long last_time; | |
void setup() { | |
Serial.begin(115200); | |
IrSender.begin(3); | |
for (uint8_t pin = 4; pin <= 7; pin++) { | |
pinMode(pin, INPUT_PULLUP); | |
} | |
} | |
void loop() { | |
if (!digitalRead(4)) IrSender.sendNEC(address, 0x01, 0); // 前進 | |
else if (!digitalRead(5)) IrSender.sendNEC(address, 0x02, 0); // 左 | |
else if (!digitalRead(6)) IrSender.sendNEC(address, 0x03, 0); // 右 | |
else if (!digitalRead(7)) IrSender.sendNEC(address, 0x04, 0); // 後退 | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment