Created
October 28, 2019 11:32
-
-
Save RobolinkAkademi/7102301b75a190377f64c158eaa58137 to your computer and use it in GitHub Desktop.
Arduino projeleri
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 <VirtualWire.h> | |
#define led 3 | |
char message[] = " "; | |
void setup() | |
{ | |
pinMode(led, OUTPUT); | |
Serial.begin(9600); | |
vw_set_ptt_inverted(true); | |
vw_set_rx_pin(11); | |
vw_setup(4000); | |
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)) | |
{ | |
message[0] = (char) buf[0]; | |
if (message[0] == '0') | |
{ | |
Serial.println(message[0]); | |
digitalWrite(led, LOW); | |
} | |
else if (message[0] == '1') | |
{ | |
Serial.println(message[0]); | |
digitalWrite(led, HIGH); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment