VS1838B to moduł odbiornika IR, który wykrywa modulowane sygnały podczerwieni z pilota i wystawia sygnał cyfrowy na OUT. Zwykle podłącza się go do VCC, GND oraz GPIO mikrokontrolera, aby odczytywać komendy IR.
| Pin | Sygnał | Opis |
|---|---|---|
OUT |
digital | Demodulated IR receiver output — connect to a microcontroller digital input |
GND |
ground | Ground reference for the IR receiver module |
VCC |
power | Positive supply for the IR receiver, typically 3.3V or 5V |
| Z | Do | Przewód |
|---|---|---|
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
board:D2 |
x1:OUT |
green |
Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.
// Canonical beginner example for the VS1838B IR Receiver
// Wiring:
// - VCC -> 5V
// - GND -> GND
// - OUT -> D2
#include <IRremote.hpp>
constexpr uint8_t IR_RECEIVE_PIN = 2;
void setup() {
Serial.begin(115200);
while (!Serial) {
;
}
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.println(F("VS1838B IR Receiver example"));
Serial.println(F("Point a TV remote at the receiver and press buttons."));
Serial.println(F("Decoded IR data will appear here."));
}
void loop() {
if (IrReceiver.decode()) {
IrReceiver.printIRResultShort(&Serial);
Serial.println();
IrReceiver.resume();
}
}
Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.
Zacznij za darmo