igendel icon

Arduino Fake Smoke Alarm Transmitter

igendel | PRO | 08/01/13 12:38:11 PM UTC | 0 ⭐ | 630 👁️ | Never ⏰ | []
C |

1.31 KB

|

None

|

0 👍

/

0 👎

// Arduino Fake Smoke Alarm Transmitter Code
// by Ido Gendel
// For the Pro Mini
#include <VirtualWire.h>
 
// Pins for activation button/sensor
#define BUTTON_PIN 12
#define BUTTON_REF 11
 
// Pin definitions for the RF transmitter
// Its 3rd pin should be connected to GND
#define DATA_PIN 2
#define POWER_PIN 3
 
// Numeric code for activation
#define CODE_LENGTH 2
 
// Actual code, could be anything
byte code[CODE_LENGTH] = {170, 205};
 
// Send activation code
void sendTrigger() {
  vw_send(code, CODE_LENGTH);
}
 
void setup() {
 
 // Prepare VirtualWire for sending 
 vw_set_tx_pin(DATA_PIN);
 vw_setup(1200); // Bits per sec 
 
 // Built-in LED will indicate transmission
 pinMode(13, OUTPUT); 
  
 // Power up the transmitter module
 pinMode(POWER_PIN, OUTPUT); 
 digitalWrite(POWER_PIN, HIGH);
 
 // Prepare button/sensor input ("open collector")
 pinMode(BUTTON_REF, OUTPUT);
 digitalWrite(BUTTON_REF, LOW);
 pinMode(BUTTON_PIN, INPUT); // Activate internal pull-up
 digitalWrite(BUTTON_PIN, HIGH);
  
}
 
void loop() {
 
  // Command detected?
  if (digitalRead(BUTTON_PIN) == LOW) {
 
    // Give visual indication
    digitalWrite(13, HIGH);
    delay(10);
    digitalWrite(13, LOW);
    // Send activation code, then wait a little
    sendTrigger();
    delay(1000);
    
  }  
 
}

Comments