summaryrefslogtreecommitdiff
path: root/trasmitter/sender.ino
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-06-09 12:55:53 +0100
committerdakkar <dakkar@thenautilus.net>2018-06-09 12:55:53 +0100
commit065835767dd877d8b0e2ccdbe5b915c5e22bd62a (patch)
treea326a82a749f47ccfc8006f806b3b0074cc3609a /trasmitter/sender.ino
parentworking sender for the CHIP (diff)
downloadthermostat-065835767dd877d8b0e2ccdbe5b915c5e22bd62a.tar.gz
thermostat-065835767dd877d8b0e2ccdbe5b915c5e22bd62a.tar.bz2
thermostat-065835767dd877d8b0e2ccdbe5b915c5e22bd62a.zip
working CHIP sender
Diffstat (limited to 'trasmitter/sender.ino')
-rw-r--r--trasmitter/sender.ino93
1 files changed, 0 insertions, 93 deletions
diff --git a/trasmitter/sender.ino b/trasmitter/sender.ino
deleted file mode 100644
index 9373875..0000000
--- a/trasmitter/sender.ino
+++ /dev/null
@@ -1,93 +0,0 @@
-const uint16_t pulseScale = 520; // usec per sample unit
-
-// alternate HIGH and LOW, first one of each array is HIGH
-const uint8_t prologue[] = {
- 1,1, 1,1, 1,1, 1,1, 1,1, 1,1,
- 2,3, 1,1, 2,2, 1,1, 1,1, 2,1,
- 1,1, 1,1, 1,2, 1,1, 1,1, 1,1,
- 1,1, 1,1,
-};
-const size_t prologueSize = sizeof(prologue) / sizeof(uint8_t);
-
-const uint8_t epilogue[] = {
- 1,2, 2,2, 1,3, // the last value doesn't much matter
-};
-const size_t epilogueSize = sizeof(epilogue) / sizeof(uint8_t);
-
-const uint8_t onSignal[] = {
- 2,2, 1,1, 1,1, 1,1, 1,1, 2,1, 1,1,
-};
-const size_t onSize = sizeof(onSignal) / sizeof(uint8_t);
-
-const uint8_t offSignal[] = {
- 1,1, 1,1, 1,1, 1,1, 1,1, 2,2, 2,1,
-};
-const size_t offSize = sizeof(offSignal) / sizeof(uint8_t);
-
-const int nTxPin = 7; // Arduino digital pin you're using for radio data.
-
-void transmitArray(const uint8_t pulses[], size_t pulseCount) {
- for(size_t idx = 0; idx < pulseCount; idx+=2) {
- digitalWrite(nTxPin, HIGH);
- delayMicroseconds(pulseScale*pulses[idx]);
-
- digitalWrite(nTxPin, LOW);
- delayMicroseconds(pulseScale*pulses[idx+1]);
- }
-}
-
-void transmitSignal(const uint8_t signal[], size_t signalSize) {
- transmitArray(prologue,prologueSize);
- transmitArray(signal,signalSize);
- transmitArray(epilogue,epilogueSize);
-}
-
-void sendTrain(const uint8_t signal[], size_t signalSize) {
- transmitSignal(signal,signalSize);
- delay(1000);
- transmitSignal(signal,signalSize);
- delay(2000);
- transmitSignal(signal,signalSize);
-}
-
-
-/**
- * The setup() function is called when a sketch starts. Used to initialize
- * variables, pin modes, start using libraries, etc. The setup function will
- * only run once, after each powerup or reset of the Arduino board.
- */
-void setup()
-{
- pinMode(nTxPin, OUTPUT);
- digitalWrite(nTxPin, LOW);
-
- Serial.begin(9600);
- Serial.println("Press 0 to turn off heating");
- Serial.println("Press 1 to turn on heating");
-
-}
-
-
-/**
- * The loop() function loops consecutively, allowing the program to change and
- * respond. Used to actively control the Arduino board.
- */
-void loop()
-{
- if (Serial.available() > 0)
- {
- int nIncomming = Serial.read();
- if (nIncomming == 49) { // char code for 1
- Serial.println("ON");
- sendTrain(onSignal,onSize);
- }
-
- if (nIncomming == 48) { // char code for 0
- Serial.println("OFF");
- sendTrain(offSignal,offSize);
- }
-
- Serial.println("Press 0 to turn off heating");
- Serial.println("Press 1 to turn on heating");
- }
-} \ No newline at end of file