
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Arduino IR transmitter</title>
	<atom:link href="http://blog.lucaseckels.com/2009/08/23/arduino-ir-transmitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lucaseckels.com/2009/08/23/arduino-ir-transmitter/</link>
	<description></description>
	<lastBuildDate>Fri, 07 Oct 2011 23:17:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Jim M</title>
		<link>http://blog.lucaseckels.com/2009/08/23/arduino-ir-transmitter/comment-page-1/#comment-1555</link>
		<dc:creator>Jim M</dc:creator>
		<pubDate>Sat, 01 Jan 2011 19:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lucaseckels.com/?p=174#comment-1555</guid>
		<description>I used your code and made a few changes. I need to control two DCT700 tuners with Mythtv. I&#039;m not a code writer, so I used your existing remote variable to select which output pin is used. I also noticed that the modulate portion was overly complex, and I had a oscope to measure the frequency and removed all the PORTB stuff. Thanks for putting this up, I was tried of using LIRC and this is much better for transmitting to both TV receivers. 


/*
&#160;*&#160;DCT700&#160;dual&#160;/Arduino&#160;IR&#160;blaster.
&#160;*&#160;
&#160;*&#160;Copyright&#160;(c)&#160;2009&#160;Alex&#160;Williamson
&#160;*
&#160;*&#160;This&#160;program&#160;is&#160;free&#160;software;&#160;you&#160;can&#160;redistribute&#160;it&#160;and/or&#160;modify
&#160;*&#160;it&#160;under&#160;the&#160;terms&#160;of&#160;version&#160;2&#160;of&#160;the&#160;GNU&#160;General&#160;Public&#160;License&#160;as
&#160;*&#160;published&#160;by&#160;the&#160;Free&#160;Software&#160;Foundation,&#160;59&#160;Temple&#160;Place,&#160;Suite&#160;330,
&#160;*&#160;Boston,&#160;MA&#160;02111-1307&#160;USA
&#160;*&#160;
&#160;*&#160;This&#160;program&#160;is&#160;distributed&#160;in&#160;the&#160;hope&#160;that&#160;it&#160;will&#160;be&#160;useful,
&#160;*&#160;but&#160;WITHOUT&#160;ANY&#160;WARRANTY;&#160;without&#160;even&#160;the&#160;implied&#160;warranty&#160;of
&#160;*&#160;MERCHANTABILITY&#160;or&#160;FITNESS&#160;FOR&#160;A&#160;PARTICULAR&#160;PURPOSE.&#160;&#160;See&#160;the
&#160;*&#160;GNU&#160;General&#160;Public&#160;License&#160;for&#160;more&#160;details.
&#160;*&#160;
&#160;*&#160;For&#160;the&#160;complete&#160;license,&#160;please&#160;see&#160;http://www.fsf.org/licenses/gpl.txt
&#160;*&#160;or&#160;request&#160;a&#160;copy&#160;from&#160;the&#160;author&#160;of&#160;this&#160;program.
&#160;*/
&#160;
&#160;/* I modified this code to modulate at exactly 38khz and use two output pins to control two DCT700&#039;s */

#include&#160;&lt;util/delay.h&gt;

/*&#160;From&#160;DCT700&#160;remote&#160;lirc&#160;files,&#160;times&#160;in&#160;us&#160;*/
#define&#160;PHEAD&#160;9000
#define&#160;SHEAD&#160;4400
#define&#160;PONE&#160;550
#define&#160;SONE&#160;4400
#define&#160;PZERO&#160;550
#define&#160;SZERO&#160;2150
#define&#160;PTRAIL&#160;550
/*&#160;for&#160;some&#160;reason&#160;the&#160;DCT700&#160;doesnt&#160;register&#160;a&#160;zero&#160;unless&#160;you&#160;send&#160;a&#160;repeat&#160;pulse&#160;after&#160;a&#160;delay&#160;ETRAIL&#160;is&#160;the&#160;delay&#160;*/
#define&#160;ETRAIL&#160;42050
#define&#160;GAP&#160;11000

#define&#160;DATA_BITS&#160;16
#define&#160;POST_BITS&#160;0

#define&#160;PERIOD_US&#160;27&#160;&#160;// ~= (1/56kHz) * 1000000

#define&#160;DEFAULT_REMOTE&#160;0x000
#define&#160;DEFAULT_REPEAT&#160;0
#define&#160;DEFAULT_DELAY&#160;250

int IR_PIN;
/*
&#160;Changed&#160;this&#160;to&#160;digitalWrite&#160;and&#160;adjusted&#160;PERIOD_US&#160;by&#160;measuring&#160;frequency&#160;on&#160;OSCOPE
&#160;*/
&#160;
static void modulate(int time)
{
	int count = time / PERIOD_US;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for(int i = 0; i &lt;= count; i++) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;digitalWrite(IR_PIN, HIGH);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;delayMicroseconds(10);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;digitalWrite(IR_PIN, LOW);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;delayMicroseconds(10);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
	
}

static void inline send_bit(int bit)
{
	if (bit) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/* Serial.print(&quot;1&quot;);*/
		modulate(PONE);
		_delay_loop_2((SONE&#160;*&#160;4)&#160;-&#160;440);
	}&#160;else {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/*  Serial.print(&quot;0&quot;); */
		modulate(PZERO);
		_delay_loop_2((SZERO&#160;*&#160;4)&#160;-&#160;250);
	}
}

static byte inline wait_for_byte()
{
	while (!&lt;b&gt;Serial&lt;/b&gt;.available());
	return &lt;b&gt;Serial&lt;/b&gt;.read();
}

static void usage(void)
{
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;Arduino dish IR blaster\n&quot;);
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;Default remote code: &quot;);
	&lt;b&gt;Serial&lt;/b&gt;.print(DEFAULT_REMOTE, DEC);
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;\nDefault repeat count: &quot;);
	&lt;b&gt;Serial&lt;/b&gt;.print(DEFAULT_REPEAT, DEC);
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;\nDefault post command delay: &quot;);
	&lt;b&gt;Serial&lt;/b&gt;.print(DEFAULT_DELAY, DEC);
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;(ms)\nCommand format: &quot;
		&#160;&#160;&#160;&#160;&#160;&quot;&lt;code&gt;[#][@][d].\n&quot;);
	&lt;b&gt;Serial&lt;/b&gt;.print(&quot;Values in decimal\n&quot;);
}

static int get_command(int *code, int *repeat, int *remote, int *delay_ms)
{
	byte data;
	int *cur;

	*code&#160;=&#160;0;
	*repeat&#160;=&#160;DEFAULT_REPEAT;
	*remote&#160;=&#160;DEFAULT_REMOTE;
	*delay_ms&#160;=&#160;DEFAULT_DELAY;

	cur&#160;=&#160;code;
	while (data = wait_for_byte()) {
		switch (data) {
			case &#039;#&#039;:
				cur&#160;=&#160;repeat;
				*cur&#160;=&#160;0;
				break;
			case &#039;@&#039;:
				cur&#160;=&#160;remote;
				*cur&#160;=&#160;0;
				break;
			case &#039;d&#039;:
				cur&#160;=&#160;delay_ms;
				*cur&#160;=&#160;0;
				break;
			case &#039;.&#039;:
				return 0;
			case &#039;0&#039; ... &#039;9&#039;:
				*cur&#160;*=&#160;10;
				*cur&#160;+=&#160;(data&#160;-&#160;&#039;0&#039;);
				break;
			default:
				usage();
				return -1;
		}
	}&#160;&#160;
}

void &lt;b&gt;setup&lt;/b&gt;()
{
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IR_PIN&#160;=&#160;13;
	pinMode(IR_PIN, OUTPUT);
	digitalWrite(IR_PIN, LOW);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IR_PIN&#160;=&#160;12;
	pinMode(IR_PIN, OUTPUT);
	digitalWrite(IR_PIN, LOW);

	&lt;b&gt;Serial&lt;/b&gt;.begin(115200);
	delay(500);
}

void &lt;b&gt;loop&lt;/b&gt;()
{
	int i, code, repeat, remote, delay_ms;
	unsigned int mask;

	while (get_command(&amp;code, &amp;repeat, &amp;remote, &amp;delay_ms) != 0);

	/*
	&#160;*&#160;Wait&#160;for&#160;serial&#160;to&#160;settle.&#160;&#160;If&#160;we&#160;get&#160;a&#160;long&#160;stream&#160;of
	&#160;*&#160;commands,&#160;we&#160;may&#160;start&#160;executing&#160;while&#160;bytes&#160;are&#160;still
	&#160;*&#160;coming&#160;in,&#160;this&#160;can&#160;affect&#160;the&#160;timing.
	&#160;*/
	do {
		i&#160;=&#160;&lt;b&gt;Serial&lt;/b&gt;.available();
		delay(1);
	}&#160;while (i != &lt;b&gt;Serial&lt;/b&gt;.available());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;/* used the &quot;remote&quot; potion of the code to switch between the two transmitters */
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;switch (remote) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;case 64:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IR_PIN&#160;=&#160;12;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;default:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IR_PIN&#160;=&#160;13;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;modulate(PHEAD);
	_delay_loop_2(SHEAD&#160;*&#160;4);

	do {
		for (mask = 0x1 &lt;&gt;= 1)
			send_bit(code&#160;&amp;&#160;mask);

		for (mask = 0x1 &lt;&gt;= 1)
			send_bit(remote&#160;&amp;&#160;mask);

		modulate(PTRAIL);
		/*_delay_loop_2((GAP * 4) - 1100);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*&#160;I&#160;found&#160;that&#160;for&#160;the&#160;DCT700,&#160;I&#160;could&#160;replace&#160;the&#160;GAP&#160;with&#160;the&#160;ETRAIL,
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*&#160;this&#160;is&#160;the&#160;only&#160;way&#160;I&#160;could&#160;get&#160;0&#160;to&#160;register.&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;*/
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;_delay_loop_2((ETRAIL&#160;*&#160;4)&#160;-&#160;1000);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;modulate(PHEAD);
	&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;_delay_loop_2(SZERO&#160;*&#160;4);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;modulate(PONE);

	}&#160;while (--repeat &gt; 0);
&lt;b&gt;Serial&lt;/b&gt;.print(&quot;\n&quot;);
	delay(delay_ms);
}

</description>
		<content:encoded><![CDATA[<p>I used your code and made a few changes. I need to control two DCT700 tuners with Mythtv. I&#8217;m not a code writer, so I used your existing remote variable to select which output pin is used. I also noticed that the modulate portion was overly complex, and I had a oscope to measure the frequency and removed all the PORTB stuff. Thanks for putting this up, I was tried of using LIRC and this is much better for transmitting to both TV receivers. </p>
<p>/*<br />
&nbsp;*&nbsp;DCT700&nbsp;dual&nbsp;/Arduino&nbsp;IR&nbsp;blaster.<br />
&nbsp;*&nbsp;<br />
&nbsp;*&nbsp;Copyright&nbsp;(c)&nbsp;2009&nbsp;Alex&nbsp;Williamson<br />
&nbsp;*<br />
&nbsp;*&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify<br />
&nbsp;*&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;version&nbsp;2&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as<br />
&nbsp;*&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;59&nbsp;Temple&nbsp;Place,&nbsp;Suite&nbsp;330,<br />
&nbsp;*&nbsp;Boston,&nbsp;MA&nbsp;02111-1307&nbsp;USA<br />
&nbsp;*&nbsp;<br />
&nbsp;*&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,<br />
&nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br />
&nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br />
&nbsp;*&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br />
&nbsp;*&nbsp;<br />
&nbsp;*&nbsp;For&nbsp;the&nbsp;complete&nbsp;license,&nbsp;please&nbsp;see&nbsp;http://www.fsf.org/licenses/gpl.txt<br />
&nbsp;*&nbsp;or&nbsp;request&nbsp;a&nbsp;copy&nbsp;from&nbsp;the&nbsp;author&nbsp;of&nbsp;this&nbsp;program.<br />
&nbsp;*/<br />
&nbsp;<br />
&nbsp;/* I modified this code to modulate at exactly 38khz and use two output pins to control two DCT700&#8242;s */</p>
<p>#include&nbsp;&lt;util/delay.h&gt;</p>
<p>/*&nbsp;From&nbsp;DCT700&nbsp;remote&nbsp;lirc&nbsp;files,&nbsp;times&nbsp;in&nbsp;us&nbsp;*/<br />
#define&nbsp;PHEAD&nbsp;9000<br />
#define&nbsp;SHEAD&nbsp;4400<br />
#define&nbsp;PONE&nbsp;550<br />
#define&nbsp;SONE&nbsp;4400<br />
#define&nbsp;PZERO&nbsp;550<br />
#define&nbsp;SZERO&nbsp;2150<br />
#define&nbsp;PTRAIL&nbsp;550<br />
/*&nbsp;for&nbsp;some&nbsp;reason&nbsp;the&nbsp;DCT700&nbsp;doesnt&nbsp;register&nbsp;a&nbsp;zero&nbsp;unless&nbsp;you&nbsp;send&nbsp;a&nbsp;repeat&nbsp;pulse&nbsp;after&nbsp;a&nbsp;delay&nbsp;ETRAIL&nbsp;is&nbsp;the&nbsp;delay&nbsp;*/<br />
#define&nbsp;ETRAIL&nbsp;42050<br />
#define&nbsp;GAP&nbsp;11000</p>
<p>#define&nbsp;DATA_BITS&nbsp;16<br />
#define&nbsp;POST_BITS&nbsp;0</p>
<p>#define&nbsp;PERIOD_US&nbsp;27&nbsp;&nbsp;// ~= (1/56kHz) * 1000000</p>
<p>#define&nbsp;DEFAULT_REMOTE&nbsp;0&#215;000<br />
#define&nbsp;DEFAULT_REPEAT&nbsp;0<br />
#define&nbsp;DEFAULT_DELAY&nbsp;250</p>
<p>int IR_PIN;<br />
/*<br />
&nbsp;Changed&nbsp;this&nbsp;to&nbsp;digitalWrite&nbsp;and&nbsp;adjusted&nbsp;PERIOD_US&nbsp;by&nbsp;measuring&nbsp;frequency&nbsp;on&nbsp;OSCOPE<br />
&nbsp;*/<br />
&nbsp;<br />
static void modulate(int time)<br />
{<br />
	int count = time / PERIOD_US;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i = 0; i &lt;= count; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(IR_PIN, HIGH);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delayMicroseconds(10);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(IR_PIN, LOW);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delayMicroseconds(10);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>}</p>
<p>static void inline send_bit(int bit)<br />
{<br />
	if (bit) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Serial.print(&#8220;1&#8243;);*/<br />
		modulate(PONE);<br />
		_delay_loop_2((SONE&nbsp;*&nbsp;4)&nbsp;-&nbsp;440);<br />
	}&nbsp;else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*  Serial.print(&#8220;0&#8243;); */<br />
		modulate(PZERO);<br />
		_delay_loop_2((SZERO&nbsp;*&nbsp;4)&nbsp;-&nbsp;250);<br />
	}<br />
}</p>
<p>static byte inline wait_for_byte()<br />
{<br />
	while (!<b>Serial</b>.available());<br />
	return <b>Serial</b>.read();<br />
}</p>
<p>static void usage(void)<br />
{<br />
	<b>Serial</b>.print(&#8220;Arduino dish IR blaster\n&#8221;);<br />
	<b>Serial</b>.print(&#8220;Default remote code: &#8220;);<br />
	<b>Serial</b>.print(DEFAULT_REMOTE, DEC);<br />
	<b>Serial</b>.print(&#8220;\nDefault repeat count: &#8220;);<br />
	<b>Serial</b>.print(DEFAULT_REPEAT, DEC);<br />
	<b>Serial</b>.print(&#8220;\nDefault post command delay: &#8220;);<br />
	<b>Serial</b>.print(DEFAULT_DELAY, DEC);<br />
	<b>Serial</b>.print(&#8220;(ms)\nCommand format: &#8221;<br />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8221;<code>[#][@][d].\n");<br />
	<b>Serial</b>.print("Values in decimal\n");<br />
}</p>
<p>static int get_command(int *code, int *repeat, int *remote, int *delay_ms)<br />
{<br />
	byte data;<br />
	int *cur;</p>
<p>	*code&nbsp;=&nbsp;0;<br />
	*repeat&nbsp;=&nbsp;DEFAULT_REPEAT;<br />
	*remote&nbsp;=&nbsp;DEFAULT_REMOTE;<br />
	*delay_ms&nbsp;=&nbsp;DEFAULT_DELAY;</p>
<p>	cur&nbsp;=&nbsp;code;<br />
	while (data = wait_for_byte()) {<br />
		switch (data) {<br />
			case '#':<br />
				cur&nbsp;=&nbsp;repeat;<br />
				*cur&nbsp;=&nbsp;0;<br />
				break;<br />
			case '@':<br />
				cur&nbsp;=&nbsp;remote;<br />
				*cur&nbsp;=&nbsp;0;<br />
				break;<br />
			case 'd':<br />
				cur&nbsp;=&nbsp;delay_ms;<br />
				*cur&nbsp;=&nbsp;0;<br />
				break;<br />
			case '.':<br />
				return 0;<br />
			case '0' ... '9':<br />
				*cur&nbsp;*=&nbsp;10;<br />
				*cur&nbsp;+=&nbsp;(data&nbsp;-&nbsp;'0');<br />
				break;<br />
			default:<br />
				usage();<br />
				return -1;<br />
		}<br />
	}&nbsp;&nbsp;<br />
}</p>
<p>void <b>setup</b>()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IR_PIN&nbsp;=&nbsp;13;<br />
	pinMode(IR_PIN, OUTPUT);<br />
	digitalWrite(IR_PIN, LOW);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IR_PIN&nbsp;=&nbsp;12;<br />
	pinMode(IR_PIN, OUTPUT);<br />
	digitalWrite(IR_PIN, LOW);</p>
<p>	<b>Serial</b>.begin(115200);<br />
	delay(500);<br />
}</p>
<p>void <b>loop</b>()<br />
{<br />
	int i, code, repeat, remote, delay_ms;<br />
	unsigned int mask;</p>
<p>	while (get_command(&amp;code, &amp;repeat, &amp;remote, &amp;delay_ms) != 0);</p>
<p>	/*<br />
	&nbsp;*&nbsp;Wait&nbsp;for&nbsp;serial&nbsp;to&nbsp;settle.&nbsp;&nbsp;If&nbsp;we&nbsp;get&nbsp;a&nbsp;long&nbsp;stream&nbsp;of<br />
	&nbsp;*&nbsp;commands,&nbsp;we&nbsp;may&nbsp;start&nbsp;executing&nbsp;while&nbsp;bytes&nbsp;are&nbsp;still<br />
	&nbsp;*&nbsp;coming&nbsp;in,&nbsp;this&nbsp;can&nbsp;affect&nbsp;the&nbsp;timing.<br />
	&nbsp;*/<br />
	do {<br />
		i&nbsp;=&nbsp;<b>Serial</b>.available();<br />
		delay(1);<br />
	}&nbsp;while (i != <b>Serial</b>.available());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* used the "remote" potion of the code to switch between the two transmitters */<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch (remote) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 64:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IR_PIN&nbsp;=&nbsp;12;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IR_PIN&nbsp;=&nbsp;13;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modulate(PHEAD);<br />
	_delay_loop_2(SHEAD&nbsp;*&nbsp;4);</p>
<p>	do {<br />
		for (mask = 0x1 &lt;&gt;= 1)<br />
			send_bit(code&nbsp;&amp;&nbsp;mask);</p>
<p>		for (mask = 0x1 &lt;&gt;= 1)<br />
			send_bit(remote&nbsp;&amp;&nbsp;mask);</p>
<p>		modulate(PTRAIL);<br />
		/*_delay_loop_2((GAP * 4) - 1100);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;I&nbsp;found&nbsp;that&nbsp;for&nbsp;the&nbsp;DCT700,&nbsp;I&nbsp;could&nbsp;replace&nbsp;the&nbsp;GAP&nbsp;with&nbsp;the&nbsp;ETRAIL,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;this&nbsp;is&nbsp;the&nbsp;only&nbsp;way&nbsp;I&nbsp;could&nbsp;get&nbsp;0&nbsp;to&nbsp;register.&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_delay_loop_2((ETRAIL&nbsp;*&nbsp;4)&nbsp;-&nbsp;1000);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modulate(PHEAD);<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_delay_loop_2(SZERO&nbsp;*&nbsp;4);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modulate(PONE);</p>
<p>	}&nbsp;while (--repeat &gt; 0);<br />
<b>Serial</b>.print("\n");<br />
	delay(delay_ms);<br />
}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn</title>
		<link>http://blog.lucaseckels.com/2009/08/23/arduino-ir-transmitter/comment-page-1/#comment-1544</link>
		<dc:creator>Glenn</dc:creator>
		<pubDate>Sun, 31 Jan 2010 17:35:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lucaseckels.com/?p=174#comment-1544</guid>
		<description>A few comments that might help others who look at this...

This program needs you to key in the OBC codes (in the serial monitor). At first I was typing in the EFC codes that OFA remotes use. They won&#039;t work here.

Here are the OBC codes for the more useful functions that don&#039;t appear on any keys on your original Samsung TV remote:

Discrete ON 153
Discrete OFF 152
Component 1 134
Component 2 136
HDMI 1 233
HDMI 2 190
HDMI 3 194
PC 105
AV 1 133
AV 2 237

These worked on my model LN-Txx61F Samsung TV. Its device code was also 7 like the program has it, but yours might be different. You might run Lucas&#039; IRMON sketch to find out what it is.

I had luck programming my learning remote by transmitting the code just once (leaving CONTINUOUS undefined). YMMV. I&#039;m not sure if Samsung complies with the special repeat code in the NEC protocol for when you hold down a key, but this program doesn&#039;t do repeats the NEC way.

I also moved the IR LED from pin 13 to 2 so I could use a smaller resistor and get a more powerful signal. In the modulate() function, I used PORTD and a mask of 0x04 to control pin 2.

Note that the NEC protocol specifies that ON_START_TIME is 9000, but Samsung deviates from this and uses 4500.

Many thanks, Lucas.</description>
		<content:encoded><![CDATA[<p>A few comments that might help others who look at this&#8230;</p>
<p>This program needs you to key in the OBC codes (in the serial monitor). At first I was typing in the EFC codes that OFA remotes use. They won&#8217;t work here.</p>
<p>Here are the OBC codes for the more useful functions that don&#8217;t appear on any keys on your original Samsung TV remote:</p>
<p>Discrete ON 153<br />
Discrete OFF 152<br />
Component 1 134<br />
Component 2 136<br />
HDMI 1 233<br />
HDMI 2 190<br />
HDMI 3 194<br />
PC 105<br />
AV 1 133<br />
AV 2 237</p>
<p>These worked on my model LN-Txx61F Samsung TV. Its device code was also 7 like the program has it, but yours might be different. You might run Lucas&#8217; IRMON sketch to find out what it is.</p>
<p>I had luck programming my learning remote by transmitting the code just once (leaving CONTINUOUS undefined). YMMV. I&#8217;m not sure if Samsung complies with the special repeat code in the NEC protocol for when you hold down a key, but this program doesn&#8217;t do repeats the NEC way.</p>
<p>I also moved the IR LED from pin 13 to 2 so I could use a smaller resistor and get a more powerful signal. In the modulate() function, I used PORTD and a mask of 0&#215;04 to control pin 2.</p>
<p>Note that the NEC protocol specifies that ON_START_TIME is 9000, but Samsung deviates from this and uses 4500.</p>
<p>Many thanks, Lucas.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

