Added send and receive.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
Code to program 433 MHz KeyFob
|
Code to program 433 MHz KeyFob
|
||||||
|
|
||||||
Transmitter must be connected to Arduino Pin #10
|
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);
|
Serial.begin(9600);
|
||||||
|
|
||||||
delay(1000);
|
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.
|
// Optional set pulse length.
|
||||||
// mySwitch.setPulseLength(320);
|
// mySwitch.setPulseLength(320);
|
||||||
@@ -36,17 +38,26 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
int i;
|
int i;
|
||||||
char buffer[40];
|
|
||||||
|
|
||||||
while (!Serial.available()) delay(10);
|
while (!Serial.available()) { // Receive Key Codes until Send was pressed
|
||||||
|
|
||||||
|
if (mySwitch.available()) {
|
||||||
|
long unsigned int value = mySwitch.getReceivedValue();
|
||||||
|
Serial.print("Receiveed Key: ");
|
||||||
|
Serial.println(value);
|
||||||
|
mySwitch.resetAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
while (Serial.available()) Serial.read();
|
while (Serial.available()) Serial.read();
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
for (i = 0; i < Keys; i++) {
|
for (i = 0; i < Keys; i++) {
|
||||||
|
|
||||||
sprintf(buffer, "Sending Key: %d, Value: %07d", i + 1, Key[i]);
|
Serial.print("Sending Key: ");
|
||||||
Serial.println(buffer);
|
Serial.print(i);
|
||||||
|
Serial.print(", Value: ");
|
||||||
|
Serial.println(Key[i]);
|
||||||
Serial.println("Press 'Send' for next Key.");
|
Serial.println("Press 'Send' for next Key.");
|
||||||
|
|
||||||
while (!Serial.available()) {
|
while (!Serial.available()) {
|
||||||
@@ -57,5 +68,5 @@ void loop() {
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
while (Serial.available()) Serial.read();
|
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.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user