Added send and receive.

This commit is contained in:
AK-Homberger
2019-09-05 19:32:54 +02:00
committed by GitHub
parent e072095b4c
commit 4cc216fed4

View File

@@ -1,7 +1,8 @@
/*
Code to program 433 MHz KeyFob
Transmitter must be connected to Arduino Pin #10
Receiver must be connected to Arduino Pin #7
*/
@@ -18,10 +19,11 @@ void setup() {
Serial.begin(9600);
delay(1000);
Serial.println("Press 'Send' to start programming!");
Serial.println("Press 'Send' to start programming or press Key on remote to see the value.");
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
mySwitch.enableTransmit(10); // Transmitter is connected to Arduino Pin #10
mySwitch.enableReceive(4); // RF Receiver on inerrupt 4 => that is pin #7 on Micro
// Optional set pulse length.
// mySwitch.setPulseLength(320);
@@ -36,18 +38,27 @@ void setup() {
void loop() {
int i;
char buffer[40];
while (!Serial.available()) { // Receive Key Codes until Send was pressed
while (!Serial.available()) delay(10);
if (mySwitch.available()) {
long unsigned int value = mySwitch.getReceivedValue();
Serial.print("Receiveed Key: ");
Serial.println(value);
mySwitch.resetAvailable();
}
}
while (Serial.available()) Serial.read();
Serial.println();
for (i = 0; i < Keys; i++) {
sprintf(buffer, "Sending Key: %d, Value: %07d", i + 1, Key[i]);
Serial.println(buffer);
Serial.println("Press 'Send' for next Key.");
Serial.print("Sending Key: ");
Serial.print(i);
Serial.print(", Value: ");
Serial.println(Key[i]);
Serial.println("Press 'Send' for next Key.");
while (!Serial.available()) {
mySwitch.send(Key[i], 24);
@@ -57,5 +68,5 @@ void loop() {
Serial.println();
while (Serial.available()) Serial.read();
}
Serial.println("Press 'Send' to start programming!");
Serial.println("Press 'Send' to start programming or press Key on remote to see the value.");
}