Stap 2: Software
RF_RECEIVER
#include int Ingang1 = 3; Arduino'nun 3. digitale pinine bağlanmıştır. int Ingang2 = 4; Arduino'nun 4. digitale pinine bağlanmıştır. Const int receive_pin = 9; void setup {delay(1000); vw_set_rx_pin(receive_pin); vw_set_ptt_inverted(true); vw_setup(2000); vw_rx_start(); pinMode (Ingang1, OUTPUT); pinMode (Ingang2, OUTPUT);} void loop {uint8_t buf [VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; als (vw_get_message (buf, & buflen)) {if(buf[0]=='1') digitalWrite(input1,HIGH); digitalWrite(input2,LOW);} if(buf[0]=='0') {digitalWrite (Ingang1 LAAG); digitalWrite(input2,LOW); } }
RF_TRANSMITTER_BUTTON #include //kütüphanemizi ekledik. Const int buton1 = 7; int butondurumu = 0;
void setup {pinMode (buton1, INPUT); vw_set_tx_pin(12); vw_setup(2000);} void loop {butondurumu = digitalRead(buton1); als (butondurumu == HIGH) {char msg [1] = {'1'}; vw_send ((uint8_t *) msg, 1); vw_wait_tx(); vertraging (100);} anders {char msg [1] = {'0'}; vw_send ((uint8_t *) msg, 1); vw_wait_tx(); vertraging (100);}}