void main(void) { uint16_t i; serialInit(9600); vw_setup(600); puts("PIC Receiver Demo\n"); vw_rx_start(); while(1) { if (vw_have_message()) { uint8_t len = VW_MAX_MESSAGE_LEN; if (vw_recv(text, &len)) { for (i = 0; i < len; i++) putchar(text[i]); putchar('\n'); } } } }
// setup the output pins and the RF link void setup() { // initialize the LED 1 pins pinMode(LED1_RED, OUTPUT); pinMode(LED1_GREEN, OUTPUT); pinMode(LED1_BLUE, OUTPUT); // initialize the LED 2 pins pinMode(LED2_RED, OUTPUT); pinMode(LED2_GREEN, OUTPUT); pinMode(LED2_BLUE, OUTPUT); _selfTest(); // Start serial communication for debug output Serial.begin(9600); Serial.println("XFVWLamp ready"); // Initialize and start VirtualWire vw_set_rx_pin(RX_PIN); // Set the receive pin to RX_PIN vw_set_tx_pin(TX_PIN); vw_set_ptt_pin(PTT_PIN); vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
int main(void) { mcusr_save = MCUSR; MCUSR = 0; wdt_disable(); if (!(mcusr_save & WDRF)) { seqnum = 0; } #ifdef SN_TEMP_DDR // configure pin for analog SN_TEMP_DDR &= ~SN_TEMP_MASK; // set as input SN_TEMP_PORT &= ~SN_TEMP_MASK; // pull-ups off DIDR0 |= SN_TEMP_MASK; // disable digital input buffer #endif SN_LED_DDR |= SN_LED_MASK; // set as output SN_LED_PORT &= ~SN_LED_MASK; vw_setup(); #ifdef SN_RX_CAPABLE vw_rx_start(); #endif for (int i=0;i<3;i++) { send_status(SN_ADDRESS_BROADCAST); vw_wait_tx(); } for (;;) { #ifdef SN_RX_CAPABLE if (vw_have_message()) { uint8_t len = sizeof(msg); if (vw_get_message((uint8_t *)&msg, &len)) { if (msg.header.destination == SN_ADDRESS_ME|| msg.header.destination == SN_ADDRESS_BROADCAST) { process_msg(); } else { // TODO - consider routing here } } else { // bad message } } #endif #ifdef SN_TX_CAPABLE // Process any outgoing stuff if (millis() - last_status > STATUS_PERIOD) { send_status(SN_ADDRESS_BROADCAST); } if (millis() - last_sensor_data > SENSOR_PERIOD) { send_sensor_data(SN_ADDRESS_BROADCAST); } #endif // SN_TX_CAPABLE #ifdef USE_MILLIS //set_sleep_mode(SLEEP_MODE_IDLE); //sleep_enable(); //sleep_cpu(); //sleep_disable(); #endif } }
///////////////////////////////////// // // Initialize the radio interface // void init_radio(void) { vw_set_ptt_pin(10); // defaults to 10 vw_set_rx_pin(11); // defaults to 11 vw_set_tx_pin(12); // defaults to 12 vw_setup(2000); // set up for 2000 bps vw_rx_start(); // start the rx radio_go = 1; // mark the rf system "up" }
void setup() { Serial.begin(9600); // Debugging only Serial.println("setup"); // Initialise the IO and ISR vw_set_ptt_inverted(true); // Required for DR3100 vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
void setup() { Serial.begin(9600); // Debugging only Serial.println("Receiver begin"); // Initialise the IO and ISR vw_setup(2000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
void setup() { Serial.begin(115200); Serial.println("setup"); pinMode( RADIO_RX, INPUT ); vw_set_rx_pin( RADIO_RX ); vw_setup(8000); // Bits per sec vw_rx_start(); // Start the receiver PLL running pinMode( STATUS_LED, OUTPUT ); digitalWrite( STATUS_LED, HIGH ); }
void setup() { // Inicializamos el monitor serie Serial.begin(9600); // Marcamos el pin del LED como salida para tenerlo de referencia pinMode(13, OUTPUT); // Inicializamos el receptor de señal vw_set_ptt_inverted(true); vw_setup(2000); vw_rx_start(); }
void setup() { delay(1000); Serial.begin( 9600 ); // Debugging only 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 lcd.begin( 16, 2 ); delay( 2000 ); }
void setup() { Serial.begin(9600); Serial.println("setup"); relays[0] = createRelay(PORT_0); relays[1] = createRelay(PORT_1); relays[2] = createRelay(PORT_2); relays[3] = createRelay(PORT_3); vw_set_rx_pin(PORT_RF); vw_setup(4000); // Bits per sec vw_rx_start(); // Start the receiver PLL running }
// initialize library and set device uid int radio_init(radio_uid uid, uint16_t speed, uint8_t tx_pin, uint8_t rx_pin, uint8_t enable_receiver) { // Serial.print("init"); state.uid = uid; vw_set_tx_pin(tx_pin); vw_set_rx_pin(rx_pin); vw_setup(speed); if( enable_receiver ){ vw_rx_start(); } }
void setup() { // initialize VirtualWire vw_set_rx_pin( rxPin ); vw_setup( BAUD ); vw_rx_start(); // initialize relay and led pins pinMode( relayPin, OUTPUT ); pinMode( ledPin, OUTPUT ); digitalWrite( ledPin, HIGH ); delay( 100 ); digitalWrite( ledPin, LOW ); delay( 100 ); digitalWrite( ledPin, HIGH ); delay( 100 ); digitalWrite( ledPin, LOW ); }
void CommClass::init() { #ifdef USE_433MHZ #ifdef WIRELESS_TRANSFER vw_set_ptt_inverted(true); vw_set_tx_pin(WIRELESS_433MHZ_TRANSFER_PIN); vw_setup(WIRELESS_SPEED);// speed of data transfer bits per second #endif #ifdef WIRELESS_RECEIVE vw_set_ptt_inverted(true); vw_set_rx_pin(WIRELESS_433MHZ_RECEIVE_PIN); vw_setup(WIRELESS_SPEED); // Bits per sec vw_rx_start(); // Start the receiver PLL running latestDataType = TYPE_NONE; #endif #endif //USE_433MHZ #ifdef USE_NRF24L rf24_module.begin(); rf24_module.setAutoAck(1); // Ensure autoACK is enabled rf24_module.enableAckPayload(); // Allow optional ack payloads rf24_module.setRetries(0, 10); // Smallest time between retries, max no. of retries rf24_module.setPayloadSize(MAX_PAYLOAD); // Here we are sending 1-byte payloads to test the call-response speed rf24_module.setDataRate(RF24_1MBPS); #ifdef WIRELESS_TRANSFER rf24_module.openWritingPipe((uint8_t*)WIRELESS_QUAD_ADDR); rf24_module.openReadingPipe(1, (uint8_t*)WIRELESS_QUAD_CTRL); #endif #ifdef WIRELESS_RECEIVE rf24_module.openWritingPipe((uint8_t*)WIRELESS_QUAD_CTRL); rf24_module.openReadingPipe(1, (uint8_t*)WIRELESS_QUAD_ADDR); #endif rf24_module.startListening(); // Start listening rf24_module.powerUp(); rf24_module.printDetails(); // Dump the configuration of the rf unit for debugging #endif //USE_NRF24L #ifdef USE_APC_220 //apc220.begin(WIRELESS_SPEED); #endif //USE_APC_220 }
/* Initialise as a listener. Must be done in the setup() function */ void RFEasy::init_listener(int pin) { _init(); //Initialization common to both transmitter and listener vw_set_rx_pin(pin); // Set transmit pin in VirtualWire vw_rx_start(); // Init as listener with VirtualWire _type = listener_type; // Set the type to listener }
void SetupRFDataRxnLink(int rx_pin, int baudRate) { vw_set_rx_pin(rx_pin); vw_setup(baudRate); vw_rx_start(); }
void setup(void) { status.reset(); /// Discrete & Analog IO pinMode(13, OUTPUT); // Arduino on-board LED pinMode(A0, OUTPUT); // Buzzer /// Comm. Channels // UART Serial.begin(115200); Serial.flush(); Serial.println("Starting up greenOmatic Duemilanove Testbed..."); Serial.print("Program compiled on "); Serial.print(__DATE__); Serial.print(" at "); Serial.println(__TIME__); Serial.println(); // RF #ifdef INTERFACE_ASK_RX pinMode(RF_RX_PIN, INPUT); vw_set_rx_pin(RF_RX_PIN); vw_setup(RF_BAUD); vw_rx_start (); Serial.print ("ASK RF Receiver configured on PIN "); Serial.print (RF_RX_PIN); Serial.print (" @ "); Serial.print (RF_BAUD, DEC); Serial.println(" baud."); #endif //INTERFACE_ASK_RX // Ethernet #ifdef INTERFACE_ETHERNET Serial.print("Starting Ethernet... "); #ifdef ETHERNET_DYNAMIC_IP int eth_stat = Ethernet.begin(mac); if (0 == eth_stat) { Serial.println(" Problem starting ethernet !"); status.ethernet_valid = status.ERROR; } else { Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; } #else Ethernet.begin(mac, IPaddr); Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; #endif //ETHERNET_DYNAMIC_IP #ifdef ETHERNET_WEBSERVER server.begin(); #endif //ETHERNET_WEBSERVER #ifdef ETHERNET_UDPCLIENT Udp.begin(localPort); #endif //ETHERNET_UDPCLIENT #endif /// Peripherals // I2C RTC #ifdef PERIPHERAL_RTCC Wire.begin(); rtc.begin(); if (rtc.isrunning()) { status.time_valid = status.VALID; GetDatetimeString(rtc.now()); Serial.print("RTCC configured on I2C. Time is currently "); Serial.println(currentTime); #ifdef ETHERNET_UDPCLIENT //TODO: Get NTP Time #else // Compare RTC time to this programs compile time DateTime rtcTime = rtc.now(); DateTime compileTime(F(__DATE__), F(__TIME__)); // If the compile-time is later (more recent) than the current RTC time, update the RTC if (compileTime.secondstime() > rtcTime.secondstime()) { Serial.println("Program compile-time is later than RTC time; updating RTC."); rtc.adjust( DateTime(F(__DATE__), F(__TIME__)) ); } #endif //ETHERNET_UDPCLIENT } else { status.time_valid = status.ERROR; // TODO, can we narrow this down further like with the DS1307RTC library? } #endif Serial.println("\nInitialization complete!\n\n"); }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO UCSCTL4 |= SELA_2; // Set ACLK = REFO UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx // Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag __bis_SR_register(SCG0); // Disable the FLL control loop UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation UCSCTL2 |= 249; // Set DCO Multiplier for 8MHz // (N + 1) * FLLRef = Fdco // (249 + 1) * 32768 = 8MHz __bic_SR_register(SCG0); // Enable the FLL control loop // Worst-case settling time for the DCO when the DCO range bits have been // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx // UG for optimization. // 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle __delay_cycles(250000); //P1DIR |= BIT0; // Set P1.0 to output direction //TA0CCTL0 = CCIE; // CCR0 interrupt enabled //TA0CTL = TASSEL_2 + MC_1 + TACLR + TAIE + ID_3; // SMCLK/8, upmode //TA0CCR0 = 0xffff; // 12.5 Hz vw_setup(1000); vw_rx_start(); P1DIR |= BIT4; /*uint8_t count = 1; while(1) { char msg[7] = {'h','e','l','l','o',' ','#'}; msg[6] = count; vw_send((uint8_t *)msg, 7); vw_wait_tx(); // Wait until the whole message is gone __delay_cycles(5/cycletime); count = count + 1; }*/ while(1) { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen = VW_MAX_MESSAGE_LEN; if (vw_get_message(buf, &buflen)) // Non-blocking { //int i; P1OUT |= BIT4; // Flash a light to show received good message __delay_cycles(1/cycletime); // Message with a good checksum received, dump it. //Serial.print("Got: "); //for (i = 0; i < buflen; i++) //{ // Serial.print(buf[i], HEX); // Serial.print(' '); //} //Serial.println(); P1OUT &= ~BIT4; } } }