Things used in this project

Hardware components:
NooElec RTL-SDR
×1
SparkFun RF Link Transmitter - 434MHz
×1
La Crosse Technology RS-204U Remote Control Outlet System
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
SparkFun RF Link Transmitter - 434MHz
×1
Software apps and online services:
SDR#
To scan and record the 434 MHz signal. I used the free version.
Audacity
To analyze the "audio" output of SDR#.

Code

Arduino 434 MHz TransmitterArduino
// Preamble common to all transmissions
static const bool preamble_bits[14] = {1,0,0,1,1,0,1,1,1,0,0,1,1,1};

// Button 1 On
static bool OneOn[24]    = {0,1,1,1,1,1,1,1,0,1,0,1, 0,1,1,1,0,0,1,1,1,0,0,1};
// Button 1 Off
static bool OneOff[24]   = {1,1,1,1,1,0,1,1,1,0,0,1, 0,1,1,1,0,0,1,1,1,0,0,1};

// Button 2 On
static bool TwoOn[24]    = {1,1,1,0,1,1,1,1,1,1,0,0, 1,1,1,0,0,0,1,1,0,0,0,0};
// Button 2 Off
static bool TwoOff[24]   = {0,1,1,0,1,0,1,1,0,0,0,0, 1,1,1,0,0,0,1,1,0,0,0,0};

// Button 3 On
static bool ThreeOn[24]  = {1,1,0,1,1,1,1,1,1,0,1,1, 1,1,0,1,0,0,1,1,1,1,1,1};
// Button 3 Off
static bool ThreeOff[24] = {0,1,0,1,1,0,1,1,1,1,1,1, 1,1,0,1,0,0,1,1,1,1,1,1};

// Button 4 On
static bool FourOn[24]   = {0,1,0,0,1,1,1,1,0,0,1,0, 0,1,0,0,0,0,1,1,0,1,1,0};
// Button 4 Off
static bool FourOff[24]  = {1,1,0,0,1,0,1,1,0,1,1,0, 0,1,0,0,0,0,1,1,0,1,1,0};

// Button All On
static bool AllOn[24]    = {0,0,1,0,1,1,1,1,0,0,0,0, 0,0,1,0,0,0,1,1,0,1,0,0};
// Button All Off
static bool AllOff[24]   = {1,0,1,0,1,0,1,1,0,1,0,0, 0,0,1,0,0,0,1,1,0,1,0,0};


// Short pulse duration (binary 0)
uint16_t short_pulse = 571;
// Long pulse duration (binary 1)
uint16_t long_pulse = 1331;
// Short delay duration (between bits)
uint16_t short_delay = 3154;
// Long delay duration (between sets)
long long_delay = 24140L;


void setup() {
  // Set pin 2 as output
  pinMode(2, OUTPUT);
  
  // Short delay to give us time to click "Record" in SDR#
  delay(1000);
}


void loop() {
  // Transmit the code for Button 1 On
  broadcast(OneOn);
  
  // Wait 5 seconds
  delay(5*1000);

  // Transmit the code for Button 1 Off
  broadcast(OneOff);
  
  // Wait 5 seconds
  delay(5*1000);
}


// Transmit the preamble
void preamble() {
  // Loop through 14 preamble bits
  for(uint8_t i=0; i<14; i++) {
    if(preamble_bits[i]==1)
      pulse_long();
    else
      pulse_short();

    delay_short();
  }
}


// Broadcast code
void broadcast(bool * Device) {
  // Repeat first set 3 times
  for(uint8_t i=0; i<3; i++) {
    // Send the preamble
    preamble();
    
    // Loop through and transmit remaining 12 bits of this set
    for(uint8_t j=0; j<12; j++) {
      if(Device[j]==1)
        pulse_long();
      else
        pulse_short();

      delay_short();
    }

    delay_long();
  }


  // Repeat second set 3 times
  for(uint8_t i=0; i<3; i++) {
    // Send the preamble
    preamble();
    
    // Loop through and transmit the remaining 12 bits of this set
    for(uint8_t j=12; j<24; j++) {
      if(Device[j]==1)
        pulse_long();
      else
        pulse_short();

      delay_short();
    }

    delay_long();
  }
}


// Send a long pulse
void pulse_long() {
  digitalWrite(2, HIGH);
  
  delayMicroseconds(long_pulse);

  digitalWrite(2, LOW);
}


// Send a short pulse
void pulse_short() {
  digitalWrite(2, HIGH);

  delayMicroseconds(short_pulse);

  digitalWrite(2, LOW);
}


// Long delay between sets
void delay_long() {
  digitalWrite(2, LOW);

  // A little hackery here since delayMicroseconds() doesn't
  // work with values over 32,767 and our long delay could
  // exceed that value.  Instead, we break it up into
  // "chunks" of 10,000 microseconds.
  for(uint8_t i=0; i<long_delay/10000; i++) {
    delayMicroseconds(10000);
  }

  // Now we delay for the remainder after the last 10,000
  // microsecond "chunk".
  delayMicroseconds(long_delay%10000);
}


// Short delay between bits
void delay_short() {
  digitalWrite(2, LOW);

  delayMicroseconds(short_delay);
}

Credits

Avatar
Garrett Bartley

Husband, father, maker.

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

The composting friend
Intermediate
  • 690
  • 34

Full instructions

Our goal is to make composting easier to use and to maintain.

An Arduino-Powered Easter Egg Printer
Intermediate
  • 1,575
  • 19

Have you started dyeing Easter eggs yet? We at ELEKS have created a smart Egg Printer powered by Arduino Uno R3.

DIGITAL BASCULE WITH ARDUINO UNO AND FSR SENSOR
Intermediate
  • 351
  • 1

Protip

The main goal is to make a practical digital bascule and using Arduino UNO board and FSR Sensor.

Automatic Fear 1.0
Intermediate
  • 349
  • 5

Full instructions

A device capable of frightening my sister and with compatibility with other members of the family

Arduino Addons : Battery Level Indicator
Intermediate
  • 2,005
  • 25

A RealTime Battery Indicator For Your Project Without Extra Components Or Using Any Analog I/Os

End-Effector and Control Logic for Robot
Intermediate
  • 3,430
  • 25

For my thesis, I have developed the control system and end-effector for a robot, easily implementable and economic.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback