Hello
here I am trying to remake an unconventional IR remote control (not working on RC5 RC6 Nec standards etc.)
I do not know the programming language at all, but I managed to search the net to create the code below
it works in part compiles and uploads to my UNO card
I specify that the reading of the buttons is done well and that the part of generation of frames also works what does not work it is the "selection" of the frame that I want to send according to the button supported
info: pressing a button generates a low state on the UNO input
my problem is that the frame is not sent when a button is pressed
if a charitable soul can give me a little help
int pinBoutonUnlock;
int pinBoutonLock;
#define Duty_Cycle 40 //in percent (10->50), usually 33 or 50
//TIP for true 50% use a value of 56, because of rounding errors
//TIP for true 40% use a value of 48, because of rounding errors
//TIP for true 33% use a value of 40, because of rounding errors
#define Carrier_Frequency 28200 //usually one of 38000, 40000, 36000, 56000, 33000, 30000
#define PERIOD (1000000+Carrier_Frequency/2)/Carrier_Frequency
#define HIGHTIME PERIOD*Duty_Cycle/100
#define LOWTIME PERIOD - HIGHTIME
#define txPinIR 8 //IR carrier output
unsigned long sigTime = 0; //use in mark & space functions to keep track of time
unsigned int Unlock[] = {8630, 2930, 950, 6830, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 10680, 950, 2930, 950, 6830, 950, 10680, 950, 6830, 950, 6830, 950, 16140, 8630, 2930, 950, 6830, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 10680, 950, 2930, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 10680, 950, 2930, 950, 6830, 950, 10680, 950, 6830, 950, 6830, 950, 16140}; //AnalysIR Batch Export (IRremote) - RAW
unsigned int Lock[] = {8630, 6830, 950, 6830, 950, 2930, 950, 10740, 950, 2930, 950, 10740, 950, 2930, 950, 10740, 950, 2940, 950, 10740, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 2930, 950, 10740, 950, 6830, 950, 2930, 950, 6830, 950, 6830, 950, 16140, 8630, 6830, 950, 6830, 950, 2930, 950, 10740, 950, 2930, 950, 10740, 950, 2930, 950, 10740, 950, 2940, 950, 10740, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 6830, 950, 2930, 950, 10740, 950, 6830, 950, 2930, 950, 6830, 950, 6830, 950, 16140}; //AnalysIR Batch Export (IRremote) - RAW
void setup() {
Serial.begin(9600);
pinBoutonUnlock=12;
pinBoutonLock=10;
pinMode(pinBoutonUnlock,INPUT);
pinMode(pinBoutonLock,INPUT);
pinMode(txPinIR,OUTPUT);
}
void loop() {
boolean etatBoutonUnlock=digitalRead(pinBoutonUnlock);
boolean etatBoutonLock=digitalRead(pinBoutonLock);
Serial.println(etatBoutonUnlock);
Serial.println(etatBoutonLock);
if (pinBoutonUnlock == LOW) {
sigTime = micros(); //keeps rolling track of signal time to avoid impact of loop & code execution delays
for (int i = 0; i < sizeof(Unlock) / sizeof(Unlock[0]); i++) {
mark(Unlock[i++]);
if (i < sizeof(Unlock) / sizeof(Unlock[0])) space(Unlock[i]);
}
}
if (pinBoutonLock == LOW) {
sigTime = micros(); //keeps rolling track of signal time to avoid impact of loop & code execution delays
for (int i = 0; i < sizeof(Lock) / sizeof(Lock[0]); i++) {
mark(Unlock[i++]);
if (i < sizeof(Lock) / sizeof(Lock[0])) space(Lock[i]);
}
}
delay(1000);
}
void mark(unsigned int mLen) { //uses sigTime as end parameter
sigTime+= mLen; //mark ends at new sigTime
unsigned long now = micros();
unsigned long dur = sigTime - now; //allows for rolling time adjustment due to code execution delays
if (dur == 0) return;
while ((micros() - now) < dur) { //just wait here until time is up
digitalWrite(txPinIR, HIGH);
delayMicroseconds(HIGHTIME - 5);
digitalWrite(txPinIR, LOW);
delayMicroseconds(LOWTIME - 6);
}
}
void space(unsigned int sLen) { //uses sigTime as end parameter
sigTime+= sLen; //space ends at new sigTime
unsigned long now = micros();
unsigned long dur = sigTime - now; //allows for rolling time adjustment due to code execution delays
if (dur == 0) return;
while ((micros() - now) < dur) ; //just wait here until time is up
}