/*
Example for different sending methods
http://code.google.com/p/rc-switch/
Need help? http://forum.ardumote.com
and
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
*/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
const int buttonPin = 9; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int lastButtonState = 0;
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Optional set pulse length.
// mySwitch.setPulseLength(320);
// Optional set protocol (default is 1, will work for most outlets)
// mySwitch.setProtocol(2);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
/* using decimal code */
/* this code is working with RPi 433mhz, 4 digits reveived */
mySwitch.send(1001, 24);
//delay(1000);
//mySwitch.send(5396, 24);
//delay(1000);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
lastButtonState = buttonState;
}