/*
SendDemo - sends RF codes.
VCC : Arduino 3.3V
GND : Arduino GND
Data : Arduino PD7
ANT : in between the two headers!
*/
#include <RCSwitch.h> //
https://github.com/sui77/rc-switch
RCSwitch mySwitch = RCSwitch();
void display_Running_Sketch (void){
String the_path = __FILE__;
int slash_loc = the_path.lastIndexOf('/');
String the_cpp_name =
the_path.substring(slash_loc+1);
int dot_loc = the_cpp_name.lastIndexOf('.');
String the_sketchname = the_cpp_name.substring(0,
dot_loc);
Serial.print("\nArduino is running Sketch: ");
Serial.println(the_sketchname);
Serial.print("Compiled on: ");
Serial.print(__DATE__);
Serial.print(" at ");
Serial.print(__TIME__);
Serial.print("\n");
}
void setup() {
Serial.begin(9600);
display_Running_Sketch();
// Data
pinMode(7, OUTPUT); // Either way, we'll use
pin 7 to drive the data pin of the transmitter.
// Transmitter is connected to Arduino Pin
#10
mySwitch.enableTransmit(7);
}
void loop() {
static int pos =0;
unsigned long value;
unsigned long channel = 0x5f5500;
int sound[] = {0x00, 0x01, 0x04, 0x05,
0x10, 0x11, 0x14, 0x15,
0x40, 0x41, 0x44, 0x45,
0x50, 0x51, 0x54, 0x55};
int pmax = sizeof(sound) / sizeof(int);
Serial.print("pmax=");
Serial.println(pmax);
value = channel + sound[pos];
Serial.print("value=");
Serial.println(value,16);
mySwitch.send(value, 24);
mySwitch.send(value, 24);
mySwitch.send(value, 24);
pos++;
if (pos == pmax) pos = 0;
delay(30000);
}
|