Here's my next contribution. I've taken my previous work with IR remote controls and worked it up into a header file. If you find it acceptable, then it might make a nice addition to the Include folder.
I put tons and tons of explanations, both hardware and software, in the file itself as comments. But I wanted to let you know here that I have tested this on two different surplus IR sensors, and two different remote controls (one surplus, one brand new) and every combination works great. I believe it will work with most any IR sensor running at a 38 kHz carrier frequency. And keep your eyes open for surplus remote controls; they show up all the time here in the US for a dollar or two. So, not only is it easy to add remote control to our projects, but it's cheap, too.
As usual, I'll start with a demo program that uses it, and attach the include file in the next posting.
;This demo prints the device number and key number sent by
;a Sony compatible IR remote control unit.
;Thomas Henry --- 4/23/2014
#chip 16F88, 8 ;PIC16F88 running at 8 MHz
#config mclr=off ;reset handled internally
#config osc=int ;use internal clock
#include <SonyRemote.h> ;include the header file
#define LCD_IO 4 ;4-bit mode
#define LCD_RS PortB.2 ;pin 8 is Register Select
#define LCD_Enable PortB.3 ;pin 9 is Enable
#define LCD_DB4 PortB.4 ;DB4 on pin 10
#define LCD_DB5 PortB.5 ;DB5 on pin 11
#define LCD_DB6 PortB.6 ;DB6 on pin 12
#define LCD_DB7 PortB.7 ;DB7 on pin 13
#define LCD_NO_RW 1 ;ground RW line on LCD
#define IR_DATA_PIN PortA.0 ;sensor on pin 17
dim device, button as byte
dir PortA in ;A.0 is IR input
dir PortB out ;B.2 - B.6 for LCD
readIR_Remote(device, button) ;wait for button press
cls ;show device code
print "Device: "
print "Button: " ;show button code
wait 10 mS ;ignore any repeats
loop ;repeat forever
Here's the header file:
And just today, the mail brought a keychain universal remote from China, and it too works with the circuit! I got this device for less than $3.00 postpaid, battery included, if you can believe that. Just hold the Mute button down continuously until the Device shows 1 and the Button shows 20, and you're set for life.
This is really cool, a tiny remote control for all sorts of projects. Here's a link to the description:
Hally, Thomas Henry!
This program is the same as in the previous...?
sony remote control commands have different topology than the other manufacturers, the first bits of the command, but after that's address bits, but for the other remote controls is in the reverse order.
I modified the code to make it suitable for an include file.
By my count, there are over fifteen different protocols in use today. Sony's is by far the most common in my country, which is why it's so easy to find control units second-hand or surplus. But, as mentioned previously, a universal remote, especially that cheap one I just described, always knows the Sony standard, and so there's no reason why a person can't put this into practice at once without spending much.
But feel free to modify the code if you think another protocol would be useful to you.
Hallo, Thomas Henry!
I do not understand how you can get 2.4 ms, and further 0.6 and 1.2 ms? I'll try to create code to another protocol.
Hallo, Thomas Henry! pulse can be used to measure the length of the command pulsein?
2.4 mS, 0.6 uS and 1.2 mS are 2400 uS, 600 uS and 1200 uS, respectively. I simply count in units of 100 uS. In other words, I look for values of 24, 6 and 12. Check out the comments in the include file.
Pulsein didn't seem to be well documented, so I just wrote my own. Again, the include file explains how it works.
Hallo, Thomas Henry!
I do not know , why command pulsein is not included in great cow basic help? For it is written here: http://www.greatcowbasic.com/gcb.html
Good point! It will be now!
Thanks for visiting my GreatCowBasic.com pages.
I originally created that command page to supplement the original limited help file
(I also have a lot to add to that command page I just need to find more time).
It all started when I was reading through the GCB source files and found many undocumented commands that have now been added to the Help file thanks to the great work by Anobium to improve it significantly.
Thanks for catching that missing PULSEIN command from the help file. I thought it was already added.
Anobium will take care of it as he usually does.
Hallo, Thomas Henry!
Please, help to create a code reader for any remote control? The idea is - reading codes from several buttons and enter them in EEPROM, so after pushing the button, these codes can recognize, change the bit values, to be operate with variety devices.
I think this could be used pulsein command, respectively, to count pulses length of the specified time period and write in EEPROM ...? I think that different remote controls for each button the time will be different.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.