示例#1
0
// 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
}
示例#2
0
/////////////////////////////////////
// 
// 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(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()
{
    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 );
}
示例#5
0
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
}
示例#6
0
文件: radio.cpp 项目: schmurfy/domo
// 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 );
}
示例#8
0
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
}
示例#9
0
文件: RFEasy.cpp 项目: houen/RFEasy
/* 
  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
}
示例#10
0
void SetupRFDataRxnLink(int rx_pin, int baudRate)
{
  vw_set_rx_pin(rx_pin);
  vw_setup(baudRate);
  vw_rx_start();
}
示例#11
0
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");
}