diff --git a/float/Tranciever_Reciever/Tranciever_Reciever.ino b/float/Tranciever_Reciever/Tranciever_Reciever.ino deleted file mode 100644 index 7637c3df..00000000 --- a/float/Tranciever_Reciever/Tranciever_Reciever.ino +++ /dev/null @@ -1,164 +0,0 @@ -// rf69 demo tx rx.pde -// -*- mode: C++ -*- -// Example sketch showing how to create a simple messaging client -// with the RH_RF69 class. RH_RF69 class does not provide for addressing or -// reliability, so you should only use RH_RF69 if you do not need the higher -// level messaging abilities. -// It is designed to work with the other example rf69_server. -// Demonstrates the use of AES encryption, setting the frequency and modem -// configuration - -#include -#include - -/************ Radio Setup ***************/ - -//yes, the key is EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE. best key ever. -uint8_t key[] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE}; - -// Change to 434.0 or other frequency, must match RX's freq! -#define RF69_FREQ 877.0 - -#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio - #define RFM69_CS 8 - #define RFM69_INT 7 - #define RFM69_RST 4 - #define LED 13 -#endif - -#if defined(ADAFRUIT_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_SAMD_FEATHER_M0) - // Feather M0 w/Radio - #define RFM69_CS 8 - #define RFM69_INT 3 - #define RFM69_RST 4 - #define LED 13 -#endif - -#if defined (__AVR_ATmega328P__) // Feather 328P w/wing - #define RFM69_INT 3 // - #define RFM69_CS 4 // - #define RFM69_RST 2 // "A" - #define LED 13 -#endif - -#if defined(ESP8266) // ESP8266 feather w/wing - #define RFM69_CS 2 // "E" - #define RFM69_IRQ 15 // "B" - #define RFM69_RST 16 // "D" - #define LED 0 -#endif - -#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) || defined(ARDUINO_NRF52840_FEATHER) || defined(ARDUINO_NRF52840_FEATHER_SENSE) - #define RFM69_INT 9 // "A" - #define RFM69_CS 10 // "B" - #define RFM69_RST 11 // "C" - #define LED 13 - -#elif defined(ESP32) // ESP32 feather w/wing - #define RFM69_RST 13 // same as LED - #define RFM69_CS 33 // "B" - #define RFM69_INT 27 // "A" - #define LED 13 -#endif - -#if defined(ARDUINO_NRF52832_FEATHER) - /* nRF52832 feather w/wing */ - #define RFM69_RST 7 // "A" - #define RFM69_CS 11 // "B" - #define RFM69_INT 31 // "C" - #define LED 17 -#endif - -/* Teensy 3.x w/wing -#define RFM69_RST 9 // "A" -#define RFM69_CS 10 // "B" -#define RFM69_IRQ 4 // "C" -#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ ) -*/ - -/* WICED Feather w/wing -#define RFM69_RST PA4 // "A" -#define RFM69_CS PB4 // "B" -#define RFM69_IRQ PA15 // "C" -#define RFM69_IRQN RFM69_IRQ -*/ - -// Singleton instance of the radio driver -RH_RF69 rf69(RFM69_CS, RFM69_INT); - -int16_t packetnum = 0; // packet counter, we increment per xmission - -void setup() -{ - Serial.begin(115200); - //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer - - Serial.println("Float Receiver"); - pinMode(LED, OUTPUT); - pinMode(RFM69_RST, OUTPUT); - digitalWrite(RFM69_RST, LOW); - - Serial.println("Feather RFM69 RX Test!"); - Serial.println(); - - // manual reset - digitalWrite(RFM69_RST, HIGH); - delay(10); - digitalWrite(RFM69_RST, LOW); - delay(10); - - if (!rf69.init()) { - Serial.println("RFM69 radio init failed"); - while (1); - } - Serial.println("RFM69 radio init OK!"); - - // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module) - // No encryption - if (!rf69.setFrequency(RF69_FREQ)) { - Serial.println("setFrequency failed"); - } - - // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the - // ishighpowermodule flag set like this: - rf69.setTxPower(20, true); // range from 14-20 for power, 2nd arg must be true for 69HCW - - // The encryption key has to be the same as the one in the server - rf69.setEncryptionKey(key); - - pinMode(LED, OUTPUT); - - Serial.print("RFM69 radio @"); Serial.print((int)RF69_FREQ); Serial.println(" MHz"); -} - - -void loop() { - if (rf69.available()) { - // Should be a message for us now - uint8_t buf[RH_RF69_MAX_MESSAGE_LEN]; - uint8_t len = sizeof(buf); - if (rf69.recv(buf, &len)) { - if (!len) return; - buf[len] = 0; - Serial.print("Received ["); - Serial.print(len); - Serial.print("]: "); - Serial.println((char*)buf); - Serial.print("RSSI: "); - Serial.println(rf69.lastRssi(), DEC); - } else { - Serial.println("Receive failed"); - } - } -} - - -void Blink(byte PIN, byte DELAY_MS, byte loops) { - for (byte i=0; i -#include -#include "RTClib.h" - -RTC_PCF8523 rtc; - -#define TEAM_NUM 42 -/************ Radio Setup ***************/ - -//If you ever forget the key, just remember that it's EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE - uint8_t key[] = { 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE}; - -// Change to 434.0 or other frequency, must match RX's freq! -#define RF69_FREQ 877.0 - -#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio - #define RFM69_CS 8 - #define RFM69_INT 7 - #define RFM69_RST 4 - #define LED 13 - -#elif defined(ADAFRUIT_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_SAMD_FEATHER_M0) - // Feather M0 w/Radio - #define RFM69_CS 8 - #define RFM69_INT 3 - #define RFM69_RST 4 - #define LED 13 - -#elif defined (__AVR_ATmega328P__) // Feather 328P w/wing - #define RFM69_INT 3 // - #define RFM69_CS 4 // - #define RFM69_RST 2 // "A" - #define LED 13 - -#elif defined(ESP8266) // ESP8266 feather w/wing - #define RFM69_CS 2 // "E" - #define RFM69_IRQ 15 // "B" - #define RFM69_RST 16 // "D" - #define LED 0 - -#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) || defined(ARDUINO_NRF52840_FEATHER) || defined(ARDUINO_NRF52840_FEATHER_SENSE) - #define RFM69_INT 9 // "A" - #define RFM69_CS 10 // "B" - #define RFM69_RST 11 // "C" - #define LED 13 - -#elif defined(ESP32) // ESP32 feather w/wing - #define RFM69_RST 13 // same as LED - #define RFM69_CS 33 // "B" - #define RFM69_INT 27 // "A" - #define LED 13 - -#elif defined(ARDUINO_NRF52832_FEATHER) - /* nRF52832 feather w/wing */ - #define RFM69_RST 7 // "A" - #define RFM69_CS 11 // "B" - #define RFM69_INT 31 // "C" - #define LED 17 - -#endif - - -/* Teensy 3.x w/wing -#define RFM69_RST 9 // "A" -#define RFM69_CS 10 // "B" -#define RFM69_IRQ 4 // "C" -#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ ) -*/ - -/* WICED Feather w/wing -#define RFM69_RST PA4 // "A" -#define RFM69_CS PB4 // "B" -#define RFM69_IRQ PA15 // "C" -#define RFM69_IRQN RFM69_IRQ -*/ - -// Singleton instance of the radio driver -RH_RF69 rf69(RFM69_CS, RFM69_INT); - -int16_t packetnum = 0; // packet counter, we increment per xmission - -void setup() -{ - Serial.begin(115200); - //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer -#ifndef ESP8266 - while (!Serial); // wait for serial port to connect. Needed for native USB -#endif - - Serial.println("Float Transmitter"); - Serial.println(); - - if (! rtc.begin()) { - Serial.println("Couldn't find RTC"); - Serial.flush(); - while (1) delay(10); - } - - if (! rtc.initialized() || rtc.lostPower()) { - Serial.println("RTC is NOT initialized, let's set the time!"); - // When time needs to be set on a new device, or after a power loss, the - // following line sets the RTC to the date & time this sketch was compiled - rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); - // This line sets the RTC with an explicit date & time, for example to set - // January 21, 2014 at 3am you would call: - // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); - // - // Note: allow 2 seconds after inserting battery or applying external power - // without battery before calling adjust(). This gives the PCF8523's - // crystal oscillator time to stabilize. If you call adjust() very quickly - // after the RTC is powered, lostPower() may still return true. - } - - rtc.start(); - - pinMode(LED, OUTPUT); - pinMode(RFM69_RST, OUTPUT); - digitalWrite(RFM69_RST, LOW); - - Serial.println("Feather RFM69 TX Test!"); - Serial.println(); - - // manual reset - digitalWrite(RFM69_RST, HIGH); - delay(10); - digitalWrite(RFM69_RST, LOW); - delay(10); - - if (!rf69.init()) { - Serial.println("RFM69 radio init failed"); - while (1); - } - Serial.println("RFM69 radio init OK!"); - // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module) - // No encryption - if (!rf69.setFrequency(RF69_FREQ)) { - Serial.println("setFrequency failed"); - } - - // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the - // ishighpowermodule flag set like this: - rf69.setTxPower(20, true); // range from 14-20 for power, 2nd arg must be true for 69HCW - - // The encryption key has to be the same as the one in the server - - rf69.setEncryptionKey(key); - - pinMode(LED, OUTPUT); - - Serial.print("RFM69 radio @"); Serial.print((int)RF69_FREQ); Serial.println(" MHz"); -} - -DateTime prevTime = new DateTime((uint32_t)0); - -void loop() { - DateTime now = rtc.now(); - - if(now.second() != prevTime.second()){ - char radiopacket[20] = ""; - - char namepacket[10] = "Team "; - itoa(TEAM_NUM, namepacket + 5, 10); - - - strcpy(radiopacket, namepacket); - strcat(radiopacket, " Time: "); - - char timepacket[10] = ""; - - sprintf (timepacket, "%u:%u:%u", now.hour(), now.minute(), now.second()); - strcat(radiopacket, timepacket); - - Serial.print("Sending: "); Serial.println(radiopacket); - - // Send a message! - rf69.send((uint8_t *)radiopacket, strlen(radiopacket)); - rf69.waitPacketSent(); - - // Now wait for a reply - uint8_t buf[RH_RF69_MAX_MESSAGE_LEN]; - uint8_t len = sizeof(buf); - - /*if (rf69.waitAvailableTimeout(500)) { - // Should be a reply message for us now - if (rf69.recv(buf, &len)) { - Serial.print("Got a reply: "); - Serial.println((char*)buf); - Blink(LED, 50, 3); //blink LED 3 times, 50ms between blinks - } else { - Serial.println("Receive failed"); - } - } else { - Serial.println("No reply."); - }*/ - - prevTime = now; - } -} - -void Blink(byte PIN, byte DELAY_MS, byte loops) { - for (byte i=0; i +#include +#include "RTClib.h" + +#if defined (__AVR_ATmega32U4__) // Feather 32u4 w/Radio +#define RFM69_CS 8 +#define RFM69_INT 7 +#define RFM69_RST 4 +#define LED 13 + +#elif defined(ADAFRUIT_FEATHER_M0) || defined(ADAFRUIT_FEATHER_M0_EXPRESS) || defined(ARDUINO_SAMD_FEATHER_M0) +// Feather M0 w/Radio +#define RFM69_CS 8 +#define RFM69_INT 3 +#define RFM69_RST 4 +#define LED 13 + +#elif defined (__AVR_ATmega328P__) // Feather 328P w/wing +#define RFM69_INT 3 // +#define RFM69_CS 4 // +#define RFM69_RST 2 // "A" +#define LED 13 + +#elif defined(ESP8266) // ESP8266 feather w/wing +#define RFM69_CS 2 // "E" +#define RFM69_IRQ 15 // "B" +#define RFM69_RST 16 // "D" +#define LED 0 + +#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) || defined(ARDUINO_NRF52840_FEATHER) || defined(ARDUINO_NRF52840_FEATHER_SENSE) +#define RFM69_INT 9 // "A" +#define RFM69_CS 10 // "B" +#define RFM69_RST 11 // "C" +#define LED 13 + +#elif defined(ESP32) // ESP32 feather w/wing +#define RFM69_RST 13 // same as LED +#define RFM69_CS 33 // "B" +#define RFM69_INT 27 // "A" +#define LED 13 + +#elif defined(ARDUINO_NRF52832_FEATHER) +/* nRF52832 feather w/wing */ +#define RFM69_RST 7 // "A" +#define RFM69_CS 11 // "B" +#define RFM69_INT 31 // "C" +#define LED 17 + +#endif + + +/* Teensy 3.x w/wing + #define RFM69_RST 9 // "A" + #define RFM69_CS 10 // "B" + #define RFM69_IRQ 4 // "C" + #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ ) +*/ + +/* WICED Feather w/wing + #define RFM69_RST PA4 // "A" + #define RFM69_CS PB4 // "B" + #define RFM69_IRQ PA15 // "C" + #define RFM69_IRQN RFM69_IRQ +*/ + +// H-bridge direction control pins +#define MOTOR_PWM 9 // Leave 100% cycle for top speed +#define MOTOR_DIR 10 // Set high for pump (CW when facing down), low for suck (CCW when facing down) + + +// Limit switch pins +#define LIMIT_FULL 6 // Low when syringe is full +#define LIMIT_EMPTY 5 // Low when syringe is empty + +#define TEAM_NUM 11 + +// Change to 434.0 or other frequency, must match RX's freq! +#define RF69_FREQ 877.0 + +#define SECOND 1000 + +// All delays in ms +#define RELEASE_MAX 1200000 +#define SUCK_MAX 45000 +#define DESCEND_TIME 5000 +#define PUMP_MAX 45000 +#define ASCEND_TIME 5000 +#define TX_MAX 60000 +#define ONE_HOUR 360000 + +#define WAIT 0 +#define SUCK 1 +#define PUMP 2 +#define STOP 3 + +unsigned long SCHEDULE[][2] = { + // Wait for max