Skip to content

Instantly share code, notes, and snippets.

@ItsAlphaNeon
Created October 13, 2023 20:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ItsAlphaNeon/6fa65265038a307ea06cc868c862dd04 to your computer and use it in GitHub Desktop.
Save ItsAlphaNeon/6fa65265038a307ea06cc868c862dd04 to your computer and use it in GitHub Desktop.
Concept code to convert Flipper Zero RAW SubGHZ recording into Arduino compatable playback code
#include <Arduino.h>
#define TRANSMIT_PIN 5
void transmit_raw(String raw_data);
String raw_data = "4569 -9174 97 -800 99 -99 -324 ..."; // add your data here.
void setup() {
Serial.begin(9600);
pinMode(TRANSMIT_PIN, OUTPUT);
// Get ready to transmit
digitalWrite(TRANSMIT_PIN, LOW);
delay(1000);
}
void loop() {
transmit_raw(raw_data);
delay(1000);
}
void transmit_raw(String raw_data) {
int16_t time;
bool value;
unsigned int data_start = 0;
unsigned int data_end = 0;
// Converting String into char array
char raw_data_array[raw_data.length() + 1];
raw_data.toCharArray(raw_data_array, raw_data.length() + 1);
// Tokenizing and sending a bit at a time.
char* token = strtok(raw_data_array, " ");
while (token != NULL) {
time = atoi(token);
// getting the high or low value of the bit.
value = time > 0 ? HIGH : LOW;
// making time positive if it is not
time = abs(time);
// sending a single bit and keeping it active for 'time' microseconds
digitalWrite(TRANSMIT_PIN, value);
delayMicroseconds(time);
// getting the next bit data.
token = strtok(NULL, " ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment