Go Down

Topic: Emulating YT-500 PanTilt remote with Arduino and HS1000A RF transmitter (Read 27 times) previous topic - next topic

Stan09

So I succeeded in emulating YT-500 PanTilt remote with this Arduino sketch:
Code: [Select]
#define dataout 11

/*here is sniffed packages produced by remote:

package starts with 9 ms HIGH (preamble)
next - 4 ms pause
next comes data (payload) represented by combinations of 1 ms HIGH
and 2 types of LOW: 1 ms and 2 ms.
for simplicity I did not decode it into bits and I am not using any libraries.
so I interpret single HIGH (1 ms) as '1'
single HIGH(1 ms), single LOW (1ms), single HIGH (1 ms) is '2'
single HIGH(1 ms), single LOW (1ms), single HIGH (1 ms), single LOW, single HIGH = '3'
and same way '4' and '5'
these 'numbers' (1,2..5) are separated by double LOW (2 ms)
While remote button is pressed same package is repeated with 18 ms breaks between packages.
so the data for 'Left' command is:
11112252541112112
right:
11112252442121121
down:
11112252343211211
up:
11112252413111313*/


 void setup()
 {
   pinMode(dataout, OUTPUT);     
   pinMode(LED_BUILTIN, OUTPUT);   
 }

 void loop(){
 send_right();
  delay(18);
 } 
     
void send_data(byte n){
    for (int i=1; i<n; i++)
    {
      digitalWrite(dataout, HIGH);   
      delayMicroseconds(550);
      digitalWrite(dataout, LOW);
      delayMicroseconds(550);     
    } 
    digitalWrite(dataout, HIGH);   
    delayMicroseconds(550);
    digitalWrite(dataout, LOW);
    delayMicroseconds(1630);
 }

 void send_header(){
     digitalWrite(dataout, HIGH);   //header
     digitalWrite(LED_BUILTIN, HIGH);
     delayMicroseconds(8900);
     
     digitalWrite(dataout,LOW);
     digitalWrite(LED_BUILTIN, LOW);
     delayMicroseconds(4450);
 }

void send_left(){
     send_header();
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(2);
     send_data(2);       
     send_data(5);
     send_data(2);
     send_data(5);         
     send_data(4);
     send_data(1);     
     send_data(1);     
     send_data(1);     
     send_data(2);
     send_data(1);         
     send_data(1);     
     send_data(2);
}

void send_right(){
     send_header();
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(2);
     send_data(2);       
     send_data(5);
     send_data(2);
     send_data(4);         
     send_data(4);
     send_data(2);     
     send_data(1);     
     send_data(2);     
     send_data(1);
     send_data(1);         
     send_data(2);     
     send_data(1);
}

void send_down(){
     send_header();
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(2);
     send_data(2);       
     send_data(5);
     send_data(2);
     send_data(3);         
     send_data(4);
     send_data(3);     
     send_data(2);     
     send_data(1);     
     send_data(1);
     send_data(2);         
     send_data(1);     
     send_data(1);
}

void send_up(){
     send_header();
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(1);
     send_data(2);
     send_data(2);       
     send_data(5);
     send_data(2);
     send_data(4);         
     send_data(1);
     send_data(3);     
     send_data(1);     
     send_data(1);     
     send_data(1);
     send_data(3);         
     send_data(1);     
     send_data(3);

package timing was measured  using Audacity;
When implementing Arduino code turned out timing needs adjusting
so this was done manually comparing original and emulated packages in Audacity.
remote contains unmarked chip in sop14 package.
Here is a package waveform for 'Left' button (beginning of next package is visible at the rightmost):

payload is interpreted as '11112252541112112' ( see description in sketch)
Arduino board used - "DCDUINO UNO"
Without any external antenna transmission distance was at least 6-7 yards (probably more, I did not test outside my apartment:)

Go Up