#include <VirtualWire.h> char msg[3] = { }; const int transmit_pin = 2; int i = 0; void setup() { vw_set_tx_pin(transmit_pin); vw_set_ptt_inverted(true); vw_setup(2000); } void loop() { vw_send((uint8_t *)msg, 70+1); vw_wait_tx(); delay(1*1000); }
Открыть пример: Online ArduBlock
#include <VirtualWire.h> char msg[3] = { }; const int transmit_pin = 2; int i = 0; void setup() { pinMode(3, INPUT_PULLUP); vw_set_tx_pin(transmit_pin); vw_set_ptt_inverted(true); vw_setup(2000); } void loop() { if (digitalRead(3) == 0) { vw_send((uint8_t *)msg, 1+1); vw_wait_tx(); } else { vw_send((uint8_t *)msg, 0+1); vw_wait_tx(); } }
Открыть пример: Online ArduBlock
#include <VirtualWire.h> const int receive_pin = 2; int ivins; long W = 0; void setup() { Serial.begin(9600); vw_set_rx_pin(receive_pin); vw_set_ptt_inverted(true); vw_setup(2000); vw_rx_start(); } void loop() { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (vw_get_message(buf, &buflen)) { for (ivins = 0; ivins < buflen-1; ivins++) { } } W = ivins; Serial.println(W); }
Открыть пример: Online ArduBlock
#include <VirtualWire.h> const int receive_pin = 2; int ivins; int x = 0; void setup() { vw_set_rx_pin(receive_pin); vw_set_ptt_inverted(true); vw_setup(2000); vw_rx_start(); } void loop() { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (vw_get_message(buf, &buflen)) { for (ivins = 0; ivins < buflen-1; ivins++) { } } x = ivins; if (x == 1) { pinMode(13, OUTPUT); digitalWrite(13, 1); } else { pinMode(13, OUTPUT); digitalWrite(13, 0); } }
Открыть пример: Online ArduBlock
Видеоурок: