Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

program of remote control

Status
Not open for further replies.

Bhuvanesh123

Advanced Member level 4
Full Member level 1
Joined
Aug 29, 2013
Messages
113
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Location
Singrauli, India, India
Visit site
Activity points
814
Code:
void setup()
{
  pinMode(15,INPUT);
  Serial.begin(9600);
}

void loop()
{
  int v=0;

  int a=pulseIn(15,LOW);
  if(a>2000)
  {
    for(int i=0;i<12;i++)  
    {
      if(pulseIn(15,LOW)>1000)//doubt is here
      {
        v=v+(1<<i);

        
      }
    }
    Serial.println(v);
    delay(500);
  }
}
code of arduino.
This is code for receiving remote signal and converting it to decimal.my protocol is of about 13 bit information. see that (pulseIn(15,LOW)>1000 line.here it receiving 12 bit of data by skipping first start bit.why it is so.
 

You are shifting only i value which is 0 to 11 to v...

Where is the actual data which you wanted to shift...
 

I don't know Arduino but if you are using TSOPxxxx to receive the IR signals then its output will be low when IR burst is detected. Ask Hexreader. He has done IR remote control. You need to use ISR to receive the bits. TSOPxxxx willl remove the carrier. You have to check the pulse duration that is ON time and OFF time and decide whether received bit is start bit or 0 bit or 1 bit.

If you use SIRC then TSOPxxxx o/p will be like

Start bit 2.4 ms low and 600 us high
bit 0 = 600 us low and 600 us high
bit 1 = 1.2 ms low and 600 us high
 

I know nothing of Arduino coding, but here is my best guess at what the program does:

Code:
// Read Sony SIRC 12 Infrared Remote Protocol
// Arduino code for 3 pin 40kHZ IR receiver chip

// initialise
void setup()
{
  pinMode(15,INPUT);       // set pin ?? as input
  Serial.begin(9600);      // 9600 baud 8,n,1
}

// keep looping to get button press information forever
void loop()
{
  int v=0;                 // initialise v (12 bit address/command store)

  int a=pulseIn(15,LOW);            // expecting start bit of 2400uS low
  if(a>2000)                        // only process message if start bit is longer than 2000uS
  {
    for(int i=0;i<12;i++)           // SIRC 12 protocol is 12 data bits (after start bit)
    {
      if(pulseIn(15,LOW)>1000)      // doubt is here - 600uS low for zero bit - so do nothing
      {                             // 1200us low for 'on'e bit, so change a single bit to a 1
        v=v+(1<<i);                 // change bit 'i' to a one if 1200uS low

        
      }
    }
    Serial.println(v);              // send the result to serial port
    delay(500);                     // stop listening for a while (maybe to ignore the repeat messages that SOny usually send)
  }
}

This site explains SIRC protocol well:
https://www.sbprojects.com/knowledge/ir/sirc.php

Do not expect exact timings from your IR receiver. Signals get distorted by the receiving circuitry, so timings will only ever be approximate.

You need to use ISR to receive the bits
I do not agree that this is always true. Many simple projects can be done without using interrupts.
 
Last edited:

pulseIn()

Description

Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.
The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length.
Syntax

pulseIn(pin, value)
pulseIn(pin, value, timeout)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top