Étape 2: logiciel
RF_RECEIVER
#include int input1 = 3 ; Arduino'nun 3. pinine numérique bağlanmıştır. input2 int = 4 ; Arduino'nun 4. pinine numérique 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 (input1, OUTPUT); pinMode (input2, OUTPUT);} void loop() {uint8_t buf [VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN ; if (vw_get_message (buf, & buflen)) {if(buf[0]=='1') digitalWrite(input1,HIGH) ; digitalWrite(input2,LOW);} if(buf[0]=='0') {digitalWrite (input1 FAIBLE) ; digitalWrite(input2,LOW) ; } }
RF_TRANSMITTER_BUTTON #include //kütüphanemizi ekledik. const int buton1 = 7 ; int butondurumu = 0 ;
void setup() {pinMode (buton1, entrée); vw_set_tx_pin(12) ; vw_setup(2000);} void loop() {butondurumu = digitalRead(buton1) ; if (butondurumu == HIGH) {char msg [1] = {"1"}; vw_send ((uint8_t *) msg, 1); vw_wait_tx() ; retard (100);} else {char msg [1] = {'0'}; vw_send ((uint8_t *) msg, 1); vw_wait_tx() ; retard (100);}}