Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* receiver.pde
- Author: Mike McCauley ([email protected])
- Copyright (C) 2008 Mike McCauley
- Modified By Muhammad Hasan
- */
- #include <VirtualWire.h>
- const int led_pin = 13;
- const int receive_pin = 12;
- void setup()
- {
- delay(1000);
- Serial.begin(9600); // Debugging only
- Serial.println("setup");
- vw_set_rx_pin(receive_pin);
- vw_set_ptt_inverted(true); // Required for DR3100
- vw_setup(2000); // Bits per sec
- vw_rx_start(); // Start the receiver PLL running
- pinMode(led_pin, OUTPUT);
- }
- void loop()
- {
- uint8_t buf[VW_MAX_MESSAGE_LEN];
- uint8_t buflen = VW_MAX_MESSAGE_LEN;
- if (vw_get_message(buf, &buflen)) // Non-blocking
- {
- int i;
- digitalWrite(led_pin, HIGH); // Flash a light to show
- received good message
- // Message with a good checksum received, dump it.
- Serial.print("Got: ");
- for (i = 0; i < buflen; i++)
- {
- Serial.print(buf[i]);
- Serial.print(' ');
- }
- Serial.println();
- digitalWrite(led_pin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment