<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5076928765077392764</atom:id><lastBuildDate>Wed, 18 Mar 2026 08:30:15 +0000</lastBuildDate><category>Arduino Uno</category><category>Arduino</category><category>Arduino Leonardo</category><category>Arduino Mega</category><category>Arduino Due</category><category>Arduino 2</category><category>Hobbist robotics</category><category>HC-SR04</category><category>Modules</category><category>Sensors</category><category>Ultrasonic sensor</category><category>LCD Module</category><category>MR007-005.1</category><category>FM Stereo</category><category>FM Stereo module</category><category>Q&amp;A</category><category>Software</category><category>arduino music</category><category>arduino sound</category><category>sonar sensor</category><category>tone music</category><category>7 segments LCD</category><category>7-seg LCD</category><category>Bots</category><category>HT1621</category><category>Robots</category><category>TEA5767</category><category>TEA5767HL</category><category>TEA5767HN</category><category>TEA5768</category><category>TEA5768HL</category><category>music</category><category>HD44780</category><category>Lost treasures</category><category>Other</category><category>PIR sensor</category><category>Passive Infrared sensor</category><category>buzzer music</category><category>multiple ultrasonic sensors</category><category>Arduino FM Radio</category><category>Clock module</category><category>DHT11</category><category>Datasheet</category><category>Frequencies distribution law</category><category>Humidity sensor</category><category>IR remote control</category><category>Infrared Remote Control</category><category>MCP79410</category><category>RTC</category><category>Real Time Clock</category><category>Remote control</category><category>Temperature sensor</category><category>Theory</category><category>motion detection</category><category>multiple HC-SR04</category><category>robotic vision</category><category>3 pin cooling fan</category><category>Beats phenomenon</category><category>Blinking led</category><category>Cooling fan</category><category>DHT22</category><category>HY45J-05A-831</category><category>Infrared sensor</category><category>LCD 2x8 (special)</category><category>LCD driving</category><category>LCD multiplexing</category><category>LCD static drive</category><category>Motors</category><category>Oversampling errors</category><category>PC cooling fan</category><category>PDC1211</category><category>RGB led</category><category>SD card reader</category><category>SD card shield</category><category>SEPA</category><category>SG90</category><category>SMD led</category><category>SPLC780D</category><category>Sampling errors</category><category>Sensor Shield</category><category>Servo motors</category><category>Shields</category><category>US-020</category><category>buzzer</category><category>conditional compilation</category><category>distance sensing</category><category>distance sensor</category><category>loudspeaker</category><title>Macduino</title><description>A small blog to register my progress in the discovery of the fantastic world of Arduino</description><link>https://macduino.blogspot.com/</link><managingEditor>noreply@blogger.com (Maczinga)</managingEditor><generator>Blogger</generator><openSearch:totalResults>49</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-7109970373894226769</guid><pubDate>Sun, 17 Dec 2017 21:24:00 +0000</pubDate><atom:updated>2017-12-18T22:32:26.046+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">7 segments LCD</category><category domain="http://www.blogger.com/atom/ns#">7-seg LCD</category><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">HT1621</category><category domain="http://www.blogger.com/atom/ns#">Software</category><title>PDC1211: a simple clock sketch</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
Hello! Upon request I&#39;ve written a very simple clock sketch. It uses the &lt;a href=&quot;https://macduino.blogspot.it/2015/02/pdc1211.html&quot;&gt;PDC1211&lt;/a&gt; library for that I wrote for a 7 segments lcd with
12 digits and 1 row. In its own turn this library is based on the &lt;a href=&quot;https://macduino.blogspot.it/2015/02/HT1621.html&quot;&gt;HT1621&lt;/a&gt; and &lt;a href=&quot;https://macduino.blogspot.it/2015/02/LiquidCrystal7S.html&quot;&gt;LiquidCrystal7S&lt;/a&gt; libraries. Please see them all for more
informations. &lt;b&gt;Enjoy!&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &amp;quot;oswald&amp;quot; , sans-serif; font-weight: bold;&quot;&gt;The sketch&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It is assumed that you use a PDC1211 module. The clock is pretty precise but to be more precise I&#39;ve added some compensation to correct
the millis lost during the lcd update operations. The compensation has been measure on an Arduino Uno module, if you use a different module,
please recompute the compensation.&lt;br /&gt;
&lt;br /&gt;
Indeed, an update is performed every 500 millis. If the variable &lt;code&gt;Blink&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt; then only the two &#39;-&#39; symbols are updated.
Otherwise, a second is passed and all the time variables are updated suitably. The first phase costs about 5 millis, the second 9 millis.
If the updating period is changed, then don&#39;t forget to measure and change those values.
&lt;br /&gt;
&lt;br /&gt;
See &lt;a href=&quot;https://macduino.blogspot.it/2015/02/pdc1211.html&quot;&gt;here&lt;/a&gt; for more informations about pin connections.
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.2em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \file clock.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \brief Simple clock for the PDC1211 library.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \date 12 17 2017&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;PDC1211.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define SS 2&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define RW 3&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define DATA 4&lt;/span&gt;

PDC1211 &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;lcd&lt;/span&gt;(SS,RW,DATA);


&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; seconds &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;55&lt;/span&gt;;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; minutes &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;59&lt;/span&gt;;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; hours &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;23&lt;/span&gt;;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; hasToUpdateHours &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;true&lt;/span&gt;;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; hasToUpdateMinutes &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;true&lt;/span&gt;;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; Blink &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;false&lt;/span&gt;;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; compensation &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;


&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
    lcd.begin();
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {

    delay(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;500&lt;/span&gt;);
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(Blink) {
        lcd.setCursor(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
        lcd.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt;);
        lcd.setCursor(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
        lcd.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt;);
        compensation &lt;span style=&quot;color: #333333;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;;

    }
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt;
    {
        lcd.home();
        &lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;seconds;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(compensation&lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1000&lt;/span&gt;) {
            &lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;seconds;
            compensation &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(seconds&lt;span style=&quot;color: #333333;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;60&lt;/span&gt;) {
            seconds &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
            &lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;minutes;
            hasToUpdateMinutes &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;true&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(minutes&lt;span style=&quot;color: #333333;&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;60&lt;/span&gt;) {
            minutes &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
            &lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;hours;
            hasToUpdateHours &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;true&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(hours &lt;span style=&quot;color: #333333;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;24&lt;/span&gt;)
            hours&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(hasToUpdateHours) {
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(hours&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;)
                lcd.print(&lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;0&#39;&lt;/span&gt;);
            lcd.print(hours);
        }
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt;
            lcd.setCursor((&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;,(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);

        lcd.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;-&quot;&lt;/span&gt;);

        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(minutes&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;)
            lcd.print(&lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;0&#39;&lt;/span&gt;);
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(hasToUpdateMinutes)
            lcd.print(minutes);
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt;
            lcd.setCursor((&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;,(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt;)&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
      
        lcd.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;-&quot;&lt;/span&gt;);
  
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(seconds&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;10&lt;/span&gt;)
            lcd.print(&lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;0&#39;&lt;/span&gt;);
        lcd.print(seconds);
  
        hasToUpdateHours &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;false&lt;/span&gt;;
        hasToUpdateMinutes &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;false&lt;/span&gt;;
        compensation &lt;span style=&quot;color: #333333;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;9&lt;/span&gt;;
    }
    Blink &lt;span style=&quot;color: #333333;&quot;&gt;^=&lt;/span&gt; &lt;span style=&quot;color: #007020;&quot;&gt;true&lt;/span&gt;;
}
&lt;/pre&gt;
&lt;/div&gt;
</description><link>https://macduino.blogspot.com/2017/12/pdc1211-simple-clock-sketch.html</link><author>noreply@blogger.com (Maczinga)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-5073702306333417192</guid><pubDate>Tue, 24 Jan 2017 21:55:00 +0000</pubDate><atom:updated>2017-01-24T23:18:28.214+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">arduino music</category><category domain="http://www.blogger.com/atom/ns#">arduino sound</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">music</category><category domain="http://www.blogger.com/atom/ns#">tone music</category><title>New tone music page!</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhyphenhyphenAm2uvyXkfyHu74_q-6Wz7uV-7yHis6kKORI5CWRYFxINFO4jDoD_nZtyE7f3-UU29KD0_a2NAdKIPrT9Dlt2lNMCnlJAN6jEptCnIy2nepeo2goLWXT-9oh8EW-lpRKnq_TLZVveZo/s1600/ATAA-2515.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhyphenhyphenAm2uvyXkfyHu74_q-6Wz7uV-7yHis6kKORI5CWRYFxINFO4jDoD_nZtyE7f3-UU29KD0_a2NAdKIPrT9Dlt2lNMCnlJAN6jEptCnIy2nepeo2goLWXT-9oh8EW-lpRKnq_TLZVveZo/s200/ATAA-2515.JPG&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
Hello! Do you like tone music? Maybe I&#39;ve something for you! I&#39;ve just started a new blog page containing my collection of tone music for Arduino. The page is accessible &lt;a href=&quot;https://macduino.blogspot.fr/p/tone-music.html&quot;&gt;here&lt;/a&gt; and from the main menu. You will find 24 items at present but the list is (slowly) growing.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;
Please have a look the following posts for the playing software and how the musics are encoded.&lt;/div&gt;
&lt;div style=&quot;padding-left: 10px; padding-top: 10px;&quot;&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;Tone music surprises!&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;Tone music: advanced playing software&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html&quot;&gt;Tone music: how to encode songs&lt;/a&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;</description><link>https://macduino.blogspot.com/2017/01/new-tone-music-page.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhyphenhyphenAm2uvyXkfyHu74_q-6Wz7uV-7yHis6kKORI5CWRYFxINFO4jDoD_nZtyE7f3-UU29KD0_a2NAdKIPrT9Dlt2lNMCnlJAN6jEptCnIy2nepeo2goLWXT-9oh8EW-lpRKnq_TLZVveZo/s72-c/ATAA-2515.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-8812802564820645100</guid><pubDate>Mon, 06 Jun 2016 16:44:00 +0000</pubDate><atom:updated>2016-06-06T19:02:29.927+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Sensors</category><category domain="http://www.blogger.com/atom/ns#">Software</category><title>ASOM (sensor library): now supporting MCP7941X </title><description>&lt;div style=&quot;text-align:justify&quot;&gt;
Another great contribution of Daniele Ratti (aka ilFuria) who added support for SRAM and EEPROM for MCP7941X.
Hope it may help. Many thanks to him.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s1600/RTC-MCP79410-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s1600/RTC-MCP79410-small.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
The new version of the sensor library can be downloaded from GitHub &lt;a href=&quot;https://github.com/maczinga/ASOM&quot;&gt;here&lt;/a&gt;.
&lt;br /&gt;&lt;br /&gt; Some other developments are in preparation (September 2016). Please come back soon!
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2016/06/another-great-contribution-of-daniele.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s72-c/RTC-MCP79410-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-6069112227035326829</guid><pubDate>Tue, 09 Jun 2015 22:11:00 +0000</pubDate><atom:updated>2015-06-10T00:11:19.784+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino FM Radio</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo module</category><title>Too bad! Norway abandoning FM Radio transmission as 2017</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK43_efLQvKBROI9-UKGpsJxj5T3gao5iUnvNl_xZPWbKDbSKNUrEQ_Ol7lIE97gfiwKH_tH5tjgj-1bPs5DcGM03M7WEq-QQFqiO3m_0SAkns4TjrRYc5_s91OG7UfNomHLBWpLQu5U0/s1600/old-time-radio.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK43_efLQvKBROI9-UKGpsJxj5T3gao5iUnvNl_xZPWbKDbSKNUrEQ_Ol7lIE97gfiwKH_tH5tjgj-1bPs5DcGM03M7WEq-QQFqiO3m_0SAkns4TjrRYc5_s91OG7UfNomHLBWpLQu5U0/s200/old-time-radio.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
Bad news for the FM radio lovers. Indeed, FM radio transmission is being progressively
dismissed in favor of digital radio. This should sound like a progress but I feel it like
a loss!
&lt;br /&gt;&lt;br /&gt;
Indeed, if FM radio transmission and reception needs a pretty limited amount of electronic
components. This &quot;easy access&quot; played a fundamental role in the past 
(think of the famous &lt;a href=&quot;http://en.wikipedia.org/wiki/Radio_Londres&quot;&gt;&quot;Radio Londres&quot;&lt;/a&gt; service of BBC during the II world war and to the multitude of
homemade receivers). Digital radio receivers won&#39;t have the same accessibility degree since
they need more sophisticated electronics.
&lt;br /&gt;&lt;br /&gt;
According to BBC (see &lt;a href=&quot;http://www.bbc.com/news/technology-32380222&quot;&gt;here&lt;/a&gt;) Norway will be the first country to stop FM transmissions. Hope the others will follow as later as possible!
&lt;br /&gt;&lt;br /&gt;
Hey, dear deciders!&lt;br /&gt; I just achieved my &lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;FM radio library&lt;/a&gt; for Arduino, please let us enjoy it!!!
&lt;br /&gt;&lt;br /&gt;
:-)
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/06/too-bad-norway-abandoning-fm-radio.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK43_efLQvKBROI9-UKGpsJxj5T3gao5iUnvNl_xZPWbKDbSKNUrEQ_Ol7lIE97gfiwKH_tH5tjgj-1bPs5DcGM03M7WEq-QQFqiO3m_0SAkns4TjrRYc5_s91OG7UfNomHLBWpLQu5U0/s72-c/old-time-radio.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-2466701704904641111</guid><pubDate>Sun, 07 Jun 2015 07:38:00 +0000</pubDate><atom:updated>2015-06-07T09:38:47.135+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">conditional compilation</category><category domain="http://www.blogger.com/atom/ns#">Q&amp;A</category><title>How to distinguish Arduino&#39;s models at compile time?</title><description>&lt;div style=&quot;text-align:justify&quot;&gt;
This is a question that you probably already asked yourself when trying to write code that must work with different Arduino&#39;s variants. Indeed, when using I2C, timers or PWM, the pins concerned on the Arduino Uno for these operations are different from Arduino Mega or form Due, etc. Hence, how to avoid the multiplication of the
source files, of the classes or to excessively overload functions?
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt; use conditional compilation!
&lt;br /&gt;
&lt;br /&gt;
In this short note we try to explain how to do that. Indeed, digging into the avr include files (see &lt;code&gt;io.h&lt;/code&gt; for example) one can find the following constants are used:
&lt;br /&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;__AVR_ATmega328P__
__AVR_ATmega328__
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
These are used to recognize that we are compiling for Arduino Uno. For the Arduino Mega we find:
&lt;br /&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;__AVR_ATmega1280__
__AVR_ATmega2560__
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
Therefore your code might look like:
&lt;br /&gt;

&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #557799&quot;&gt;#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328P__)&lt;/span&gt;
  
  [your arduino uno code here]
  
&lt;span style=&quot;color: #557799&quot;&gt;#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)&lt;/span&gt;

  [your arduino mega code here]
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Enjoy!&lt;/h4&gt;

&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/06/how-to-distinguish-arduinos-models.html</link><author>noreply@blogger.com (Maczinga)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-765278679663545790</guid><pubDate>Sat, 06 Jun 2015 06:56:00 +0000</pubDate><atom:updated>2015-06-11T14:40:03.519+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Bots</category><category domain="http://www.blogger.com/atom/ns#">HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">Hobbist robotics</category><category domain="http://www.blogger.com/atom/ns#">multiple HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">multiple ultrasonic sensors</category><category domain="http://www.blogger.com/atom/ns#">Robots</category><category domain="http://www.blogger.com/atom/ns#">Ultrasonic sensor</category><title>Sonar robot (multiple HC-SR04): Gastaud&#39;s version</title><description>&lt;div style=&quot;text-align:justify&quot;&gt;
Here is one more version of the sonar robot we have seen &lt;a href=&quot;http://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04.html&quot;&gt;here&lt;/a&gt;. I would like to stress how fluid is the navigation of the robot. Give a look at the short movie to get convinced!
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Photos&lt;/h4&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUyg6eBT773LSyj9NDXJwspjZ3ew4xChvHU5KYMtz-PyvTH1cIrFVT9xxVAmgIOE075w5DA0_I0fZenUtAzIGk7hJrgT10S2Ql15Jo8svJl_kWKEKfO_e8sI85xcnH_OglDqgp1UppvOQ/s1600/gastaud-bottom-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUyg6eBT773LSyj9NDXJwspjZ3ew4xChvHU5KYMtz-PyvTH1cIrFVT9xxVAmgIOE075w5DA0_I0fZenUtAzIGk7hJrgT10S2Ql15Jo8svJl_kWKEKfO_e8sI85xcnH_OglDqgp1UppvOQ/s320/gastaud-bottom-small.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Bottom view.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhnD2aVe7jHP-O9_8tO5RvfDRqiRmLjUp0byWuefF9ZcWwzOr3Fjf9Yota5u4_k_5HOSvwWmpON1JqFjTKHBNg2xAIAkuQz9ClT95QEGOTqfzKPam2IJJ6UG3DrYYCeNRFtvGwGawzr4c/s1600/gastaud-front-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhnD2aVe7jHP-O9_8tO5RvfDRqiRmLjUp0byWuefF9ZcWwzOr3Fjf9Yota5u4_k_5HOSvwWmpON1JqFjTKHBNg2xAIAkuQz9ClT95QEGOTqfzKPam2IJJ6UG3DrYYCeNRFtvGwGawzr4c/s320/gastaud-front-small.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Front view.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhptIPaXxbUP1W36UHLmGVz6w-de7UDAniSaailNF6hxeDYK77vRx81Aa0Gsb0UvUvWAktLTGUqJYty-AUia_GGMKORbczZsFx7EGEss1br8nggcd4HvbH1TARubZwpG10REQW5Ttm9w6k/s1600/gastaud-top-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhptIPaXxbUP1W36UHLmGVz6w-de7UDAniSaailNF6hxeDYK77vRx81Aa0Gsb0UvUvWAktLTGUqJYty-AUia_GGMKORbczZsFx7EGEss1br8nggcd4HvbH1TARubZwpG10REQW5Ttm9w6k/s320/gastaud-top-small.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Top view.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;The movie&lt;/h4&gt;
Look at the robot moving in an homemade arena. It seems human operated but it is not!
Just try yourself if you don&#39;t trust me.
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_WHpJWDJ5ckYxQU0/view?usp=sharing&quot;&gt;High quality&lt;/a&gt; (345MB)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_aUJ4ZWVReU9OU3c/view?usp=sharing&quot;&gt;Low quality&lt;/a&gt; (35MB)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;
&lt;script async=&quot;&quot; src=&quot;//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
&lt;!-- macduino-inner-page-adattabile --&gt;
&lt;br /&gt;
&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-5381535779269301&quot; data-ad-format=&quot;auto&quot; data-ad-slot=&quot;6603614070&quot; style=&quot;display: block;&quot;&gt;&lt;/ins&gt;&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;The sketch&lt;/h4&gt;
Look at &lt;a href=&quot;http://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04.html&quot;&gt;here&lt;/a&gt; for the libraries. The main program is not yet greatly optimized (not the main goal at present) but it works smoothly.
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_UnRSQ1p5bEYzQUk/view?usp=sharing&quot;&gt;gastaud2.ino&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Enjoy!&lt;/h4&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/06/sonar-robot-multiple-hc-sr04-gastauds.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUyg6eBT773LSyj9NDXJwspjZ3ew4xChvHU5KYMtz-PyvTH1cIrFVT9xxVAmgIOE075w5DA0_I0fZenUtAzIGk7hJrgT10S2Ql15Jo8svJl_kWKEKfO_e8sI85xcnH_OglDqgp1UppvOQ/s72-c/gastaud-bottom-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-3507981727257195604</guid><pubDate>Sun, 31 May 2015 20:04:00 +0000</pubDate><atom:updated>2015-05-31T22:04:50.883+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Sensors</category><category domain="http://www.blogger.com/atom/ns#">Software</category><title>ASOM (sensor library): update and bug fixes</title><description>&lt;div style=&quot;text-align:justify&quot;&gt;
Many many thanks to Daniele Ratti who made a lot of improvements to the section concerning the &lt;span style=&quot;color: #3d85c6;&quot;&gt;RTC module&lt;/span&gt;. He made also some bug fixes and tested all the procedures.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s1600/RTC-MCP79410-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s1600/RTC-MCP79410-small.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
The new version of the sensor library can be downloaded from GitHub &lt;a href=&quot;https://github.com/maczinga/ASOM&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/05/asom-sensor-library-update-and-bug-fixes.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_R_o9JnPgW_LnuDpRBlqTve1dZEG9jlwJWnWDY5nIf3dq4SLCFybwJNRz2mquZ088EdR11YOfdObK6C2gMxiBfcshjNNI6CKNPLLvqFFIaCJvdEj2lmGk-N8leinAox5hVE6Kti8lko/s72-c/RTC-MCP79410-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-1724515996770597858</guid><pubDate>Sat, 30 May 2015 10:39:00 +0000</pubDate><atom:updated>2015-05-31T09:39:18.905+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Bots</category><category domain="http://www.blogger.com/atom/ns#">HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">Hobbist robotics</category><category domain="http://www.blogger.com/atom/ns#">Robots</category><category domain="http://www.blogger.com/atom/ns#">Ultrasonic sensor</category><title>Sonar robot (multiple HC-SR04): the components list</title><description>&lt;div style=&quot;text-align:justify&quot;&gt;
Here is the list of the modules, motors etc. that has been used to build the
&lt;a href=&quot;http://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04.html&quot;&gt;sonar robot&lt;/a&gt;. All the material can be easily found in specialized shop or on Ebay for few
Euros. Pay attention to the version of the motor shield you have. It has to match
the version of the library you have installed.
&lt;br /&gt;
&lt;br /&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWdBj4TOqvXUQAwQxyXjbg4s0lQJoeHj6acRt1N97wp8X4NC5ARYe6yXN311eeMK65feOUpXgltMo-UKRyKtlBEX4PcC2MMS17zUkTE5DORUa4wscNUTJGjNvDXIkCwrIwbUGCHuVzmNQ/s1600/DCmotor-3-6V-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWdBj4TOqvXUQAwQxyXjbg4s0lQJoeHj6acRt1N97wp8X4NC5ARYe6yXN311eeMK65feOUpXgltMo-UKRyKtlBEX4PcC2MMS17zUkTE5DORUa4wscNUTJGjNvDXIkCwrIwbUGCHuVzmNQ/s200/DCmotor-3-6V-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;
&lt;/td&gt;&lt;td&gt;2x DC Motor 3-6V and their wheels and tyres&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHQyYavKTnAdtiGI00ncdXzGpUzertaamOGA80ThwChviDTweTJpyegkDTUsJ-jc_Qt55H_JyZsPcXfPOsvGKqXVVHcBIrw-BWEISOCs2C1DlBn7qTcugefdUgN94WVilTpsOXKO_nYKE/s1600/Caster-Wheel-Fixed.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHQyYavKTnAdtiGI00ncdXzGpUzertaamOGA80ThwChviDTweTJpyegkDTUsJ-jc_Qt55H_JyZsPcXfPOsvGKqXVVHcBIrw-BWEISOCs2C1DlBn7qTcugefdUgN94WVilTpsOXKO_nYKE/s320/Caster-Wheel-Fixed.jpg&quot; width=&quot;60&quot; /&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;
1x fixed wheel caster
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXDswe221QsyU-JJeCD42BYl6ZjUWizHSG3LHUaS_QhUYs_iH_NEtaNGreUVQ-icUVYK0hQCJ5PKqvwkL1Z8UwWTREC1VAaVPrw-zZ-xOhqMyfvXYXlQcxSI_d33AEBSUULi9uqFTDC-s/s1600/motor-shield-ada1438-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXDswe221QsyU-JJeCD42BYl6ZjUWizHSG3LHUaS_QhUYs_iH_NEtaNGreUVQ-icUVYK0hQCJ5PKqvwkL1Z8UwWTREC1VAaVPrw-zZ-xOhqMyfvXYXlQcxSI_d33AEBSUULi9uqFTDC-s/s320/motor-shield-ada1438-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;
Motor Shield Adafruit 1438
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9T2GSx-bTzcifX-k8a0dEBn1wQ1xJZ6jj9Wi_GY8Np4TJ2GWZPFN94dvpb-JvELPHjV54it2y9YMx4FCA3Ai7B-y1mnwYHRLkFBNjcQIT7Bh1FmBZUCiYxG9JaHdpCrvB3yxSmSTGZwc/s1600/HC-SR04-fronte-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9T2GSx-bTzcifX-k8a0dEBn1wQ1xJZ6jj9Wi_GY8Np4TJ2GWZPFN94dvpb-JvELPHjV54it2y9YMx4FCA3Ai7B-y1mnwYHRLkFBNjcQIT7Bh1FmBZUCiYxG9JaHdpCrvB3yxSmSTGZwc/s320/HC-SR04-fronte-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;3x Ultrasonic sensor HC-SR04 (or similar)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgihCLl3LA8lvrX2Ff8MqQK6DsCQeEx2GpkgMlZ4To-cvh3LFwYO8ESH16AvbIBKgw-HoeMn7Uvbd9qUcyYCs7D6s-4FBcqqyIbUuBTyiVkS8NcxUBLqnSendvTX8W6Goncoygqj_vmsao/s1600/Mini+Solderless+Prototype+Breadboard-Blue-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgihCLl3LA8lvrX2Ff8MqQK6DsCQeEx2GpkgMlZ4To-cvh3LFwYO8ESH16AvbIBKgw-HoeMn7Uvbd9qUcyYCs7D6s-4FBcqqyIbUuBTyiVkS8NcxUBLqnSendvTX8W6Goncoygqj_vmsao/s320/Mini+Solderless+Prototype+Breadboard-Blue-small.jpg&quot;  width=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;180 points prototype mini-breadboard (or similar)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghi-gTPUwZYlRGxBKlzI2d9yjjH4wWxLTfl_2AHiAmln7eRfBuBbqsCnQe187kFo6NGI45GLW1SUUcB8YAEFF26YDRQaF67K26ZMXkR3qPHjHKof8nwr_0QxW70n6Iy86izdcBCD2zpdo/s1600/Cavi-arduino-160-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghi-gTPUwZYlRGxBKlzI2d9yjjH4wWxLTfl_2AHiAmln7eRfBuBbqsCnQe187kFo6NGI45GLW1SUUcB8YAEFF26YDRQaF67K26ZMXkR3qPHjHKof8nwr_0QxW70n6Iy86izdcBCD2zpdo/s320/Cavi-arduino-160-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;A bunch of cables (male-female and male-male)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMFTKSTUQ8xet-UNaPAKil_TYfV4hYHmh3SdiaKrlYcnwiQR5IWiNSgmJ8uj6Zt_3e29InYA8kCf7211zX9_EkzyGLnxcfy9ig_sXbCjMsJ33FO4o-w_MZmnRgDz2so3KgXsqrfnPNJio/s1600/patafix-blanc-small.jpg&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMFTKSTUQ8xet-UNaPAKil_TYfV4hYHmh3SdiaKrlYcnwiQR5IWiNSgmJ8uj6Zt_3e29InYA8kCf7211zX9_EkzyGLnxcfy9ig_sXbCjMsJ33FO4o-w_MZmnRgDz2so3KgXsqrfnPNJio/s320/patafix-blanc-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Patafix or blue tack&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUQEkrxgeFYPUiDLhlaR06OX1YgWKEKLkIZRkLff7DGEETo8DiOhVb6JAJFz50vo0oGBFT2a67pB68VL_5b24CC-FoPoNkDh9kLZcMazYem6yrSI4NbvhA81fnY0qsZlCsGkt0tpSmnLk/s1600/bi-adesive-velcro-stripes-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUQEkrxgeFYPUiDLhlaR06OX1YgWKEKLkIZRkLff7DGEETo8DiOhVb6JAJFz50vo0oGBFT2a67pB68VL_5b24CC-FoPoNkDh9kLZcMazYem6yrSI4NbvhA81fnY0qsZlCsGkt0tpSmnLk/s320/bi-adesive-velcro-stripes-small.jpg&quot;  width=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Bi-adesive velcro stripe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiol6NSge9PYgJMijF0-FWb9eYHvrtda5rP4BvcRdkqH8o7zquuSpmuiIchkVDK8x9dEle_tdIRjWnvXcSIA1AEO9vEFcVLSH7ClHNisXBRlEFJgWcGgJGaklUbx_I7_bvphnn9FrNitC0/s1600/8mm-clear-acrylic-sheet-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiol6NSge9PYgJMijF0-FWb9eYHvrtda5rP4BvcRdkqH8o7zquuSpmuiIchkVDK8x9dEle_tdIRjWnvXcSIA1AEO9vEFcVLSH7ClHNisXBRlEFJgWcGgJGaklUbx_I7_bvphnn9FrNitC0/s320/8mm-clear-acrylic-sheet-small.jpg&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;8mm acrylic sheet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTcBOL2fePPILaqTaGoDOzHORBOL0hO0-7NcJi_b44olC2kJTGqLEscqsWMa6H2lmNcBloip0Z5HUxm5AdFHnu5faNRAFMgB1on4vM0pbg01mHH9iZmCF9u_vl_LUv_UqTZ6fa_Z9lhsg/s1600/ArduinoUno-R3-Front-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: .2em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTcBOL2fePPILaqTaGoDOzHORBOL0hO0-7NcJi_b44olC2kJTGqLEscqsWMa6H2lmNcBloip0Z5HUxm5AdFHnu5faNRAFMgB1on4vM0pbg01mHH9iZmCF9u_vl_LUv_UqTZ6fa_Z9lhsg/s320/ArduinoUno-R3-Front-small.jpg&quot; width=&quot;100&quot;/&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;...and your friend Arduino!&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04-material.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWdBj4TOqvXUQAwQxyXjbg4s0lQJoeHj6acRt1N97wp8X4NC5ARYe6yXN311eeMK65feOUpXgltMo-UKRyKtlBEX4PcC2MMS17zUkTE5DORUa4wscNUTJGjNvDXIkCwrIwbUGCHuVzmNQ/s72-c/DCmotor-3-6V-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-3192525153280165260</guid><pubDate>Sat, 30 May 2015 10:39:00 +0000</pubDate><atom:updated>2018-01-24T16:51:48.827+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Bots</category><category domain="http://www.blogger.com/atom/ns#">HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">Hobbist robotics</category><category domain="http://www.blogger.com/atom/ns#">multiple HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">multiple ultrasonic sensors</category><category domain="http://www.blogger.com/atom/ns#">Robots</category><category domain="http://www.blogger.com/atom/ns#">Ultrasonic sensor</category><title>Sonar Robot (multiple HC-SR04)</title><description>A big bravo to the students of Complexity class of &lt;a href=&quot;http://unice.fr&quot;&gt;Nice Sophia Antipolis University&lt;/a&gt; (France)!
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Following the guidelines of &lt;a href=&quot;http://macduino.blogspot.com/2013/11/hc-sr04-using-multiple-ultrasonic.html&quot;&gt;this&lt;/a&gt; post, the students realized an explorer robot which can
perform some basic obstacle avoidance.
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Some photos&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6QZ2ckGW9oe44atPHrnhek_FbVwgqrM-Ne-jWmawu83WKFGuZ7EMTFHFr5zyGtLfxt4Kc1I5BVio9wSt8b9oypFsW6ombLJ3oIy1YAUkxzbsnryAM8IhZaBELFQkStuq-5-bdFO1UXEo/s1600/SonarBot2-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6QZ2ckGW9oe44atPHrnhek_FbVwgqrM-Ne-jWmawu83WKFGuZ7EMTFHFr5zyGtLfxt4Kc1I5BVio9wSt8b9oypFsW6ombLJ3oIy1YAUkxzbsnryAM8IhZaBELFQkStuq-5-bdFO1UXEo/s320/SonarBot2-small.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpq3VStqquSc-PTxpXLhyC5jfOkvst5G5tKHA8AXV-PEDYNd3djnzm58b_xj6c6FCkfI8IPL_d21YfFXM4ImQvCvzdQcaxWMy76hoXCzkitlmM7GmVmd9c4bem6J6XlkeIUnG9nxH6MNo/s1600/SonarBot4-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpq3VStqquSc-PTxpXLhyC5jfOkvst5G5tKHA8AXV-PEDYNd3djnzm58b_xj6c6FCkfI8IPL_d21YfFXM4ImQvCvzdQcaxWMy76hoXCzkitlmM7GmVmd9c4bem6J6XlkeIUnG9nxH6MNo/s320/SonarBot4-small.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiusCB-NxlHCKF0Nrv5teGVdOVVeVCR_0cpcsgHwzIXtHHatx-89D8CJ_eUPdMIik_129AsZbjA_6R3cTPfnGb-RjtdPbavAB9W30c2JoR5ldwapTEtlJb2J-LKfoqfcVXpRsOUQgDfwHw/s1600/SonarBot5-small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiusCB-NxlHCKF0Nrv5teGVdOVVeVCR_0cpcsgHwzIXtHHatx-89D8CJ_eUPdMIik_129AsZbjA_6R3cTPfnGb-RjtdPbavAB9W30c2JoR5ldwapTEtlJb2J-LKfoqfcVXpRsOUQgDfwHw/s320/SonarBot5-small.jpg&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
The material&lt;/h4&gt;
The complete list of components and all the materials used to build the robot can be found &lt;a href=&quot;http://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04-material.html&quot;&gt;here&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;The software&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
AF_Motor library (download it from GitHub &lt;a href=&quot;https://github.com/adafruit/Adafruit-Motor-Shield-library/zipball/master&quot;&gt;here&lt;/a&gt; and follow &lt;a href=&quot;https://learn.adafruit.com/adafruit-motor-shield/library-install&quot;&gt;this&lt;/a&gt; guidelines for its installation)&lt;/li&gt;
&lt;li&gt;HC-SR04 programming guidelines found &lt;a href=&quot;http://macduino.blogspot.com/2013/11/HC-SR04-part1.html&quot;&gt;here&lt;/a&gt; (see also the connected links)&lt;/li&gt;
&lt;li&gt;Homebrewed artificial intelligence inspired from &lt;a href=&quot;http://macduino.blogspot.com/2013/11/hc-sr04-using-multiple-ultrasonic.html&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h4&gt;More photos, movies and software&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt; &lt;a href=&quot;http://macduino.blogspot.com/2015/06/sonar-robot-multiple-hc-sr04-gastauds.html&quot;&gt;Gastaud&#39;s version&lt;/a&gt;
&lt;li&gt; &lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_TmUzaWl1MTd2SVU/view?usp=sharing&quot;&gt;{Balde, Diallo, Moulayeely, Yacoub}&#39;s version&lt;/a&gt; (source code only)&lt;/li&gt;
&lt;li&gt;More to come!&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Enjoy!&lt;/h4&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/05/sonar-robot-multiple-hc-sr04.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6QZ2ckGW9oe44atPHrnhek_FbVwgqrM-Ne-jWmawu83WKFGuZ7EMTFHFr5zyGtLfxt4Kc1I5BVio9wSt8b9oypFsW6ombLJ3oIy1YAUkxzbsnryAM8IhZaBELFQkStuq-5-bdFO1UXEo/s72-c/SonarBot2-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-5574955479571969167</guid><pubDate>Sun, 15 Mar 2015 21:30:00 +0000</pubDate><atom:updated>2015-03-15T22:32:41.540+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Passive Infrared sensor</category><category domain="http://www.blogger.com/atom/ns#">PIR sensor</category><category domain="http://www.blogger.com/atom/ns#">Q&amp;A</category><category domain="http://www.blogger.com/atom/ns#">Sensors</category><title>PIR sensors: exploiting passivity</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
We have already spoken about the PIR sensor in these pages (see &lt;a href=&quot;http://macduino.blogspot.com/2013/11/PIR-sensor.html&quot;&gt;here&lt;/a&gt;) and many other pointers can be found on the web. However, the example sketches does never consider the main aspect of this sensor: passivity! The sketches always employ busy waiting (ie they continuously loop on the test for changes over the alarm pin). 
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga-tUlxowX_vuue4hYojumZDXIdj86oYq7lWlX1vnBitTdpeIT3biaLzWNWM3FeGv6s3X6SjslJYrfi3nO9yrS9BgNBJS-Lw6Q04x9hd31FTYHwk0hfWX5BcW1XjAcVBHX8NhiUJm_Tqo/s1600/PIR-front.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga-tUlxowX_vuue4hYojumZDXIdj86oYq7lWlX1vnBitTdpeIT3biaLzWNWM3FeGv6s3X6SjslJYrfi3nO9yrS9BgNBJS-Lw6Q04x9hd31FTYHwk0hfWX5BcW1XjAcVBHX8NhiUJm_Tqo/s1600/PIR-front.png&quot; height=&quot;181&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;The PIR sensor used in the sketch.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
The idea&lt;/h4&gt;
Use interrupts! The idea is that the alarm function is activated by
the state change of the signal pin of the sensor. In this way the CPU can perform
other tasks when the alarm is not activated.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Remark&lt;/h4&gt;
When the alarm is triggered on the PIR sensor it remains in this state for a certain
amount of time. Since we chose to implement the &lt;code&gt;CHANGE&lt;/code&gt; option for the
interrupt routine we have to prevent that the service routine is run twice instead
of once. This is implemented using a simple flag.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;The sketch&lt;/h4&gt;
Since the sketch has only prototyping purposes, the only effect of the alarm trigger is
to print a message to the serial monitor. To see the message open the serial monitor,
choose the right port and communication speed.
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * PIRpassExploit&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * A convenient way to use PIR sensors&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \date 15 March 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \copyright BSD license, check the License page on the blog for&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * more information. All this text must be included in any &lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * Remarks:&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * - OUT pin is connected to digital pin 2 of Arduino, change this&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *   if needed&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * - DELAY times depend on the type of module and/or its &lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *   configuration.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #888888&quot;&gt;// OUT pin on PIR sensor connected to digital pin 2&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// (any other digital pin will do, just change the value below)&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define PIRSensorPin 2&lt;/span&gt;

&lt;span style=&quot;color: #888888&quot;&gt;// This is the amount that the sensor takes to setup internals&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// Check your sensor datasheet for the correct value&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// Mine is about 17 seconds&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define PIR_INIT_DELAY 17000&lt;/span&gt;

&lt;span style=&quot;color: #888888&quot;&gt;// This is used to avoid triggering alarm twice when signal returns&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// to normal state&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;volatile&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; alarmUnarmed;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;doAlarm&lt;/span&gt;() {
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(alarmUnarmed) {
    alarmUnarmed &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020&quot;&gt;false&lt;/span&gt;;    
    Serial.println(&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Alarm triggered!&amp;quot;&lt;/span&gt;);
  }
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;else&lt;/span&gt;
    alarmUnarmed &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020&quot;&gt;true&lt;/span&gt;;
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {
  Serial.begin(&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;9600&lt;/span&gt;);
  
  pinMode(PIRSensorPin, INPUT);
  delay(PIR_INIT_DELAY);
  
  alarmUnarmed &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020&quot;&gt;true&lt;/span&gt;;
  attachInterrupt(&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;, doAlarm, CHANGE);
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {

  &lt;span style=&quot;color: #888888&quot;&gt;// do some good work here ;-)&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;See also&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/11/PIR-sensor.html&quot;&gt;The PIR sensor&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/02/hc-sr04-motion-detection.html&quot;&gt;Using HC-SR04 as a motion sensor&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;Enjoy!&lt;/h4&gt;</description><link>https://macduino.blogspot.com/2015/03/pir-sensor-exploiting-passivity.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga-tUlxowX_vuue4hYojumZDXIdj86oYq7lWlX1vnBitTdpeIT3biaLzWNWM3FeGv6s3X6SjslJYrfi3nO9yrS9BgNBJS-Lw6Q04x9hd31FTYHwk0hfWX5BcW1XjAcVBHX8NhiUJm_Tqo/s72-c/PIR-front.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-3180525338672847995</guid><pubDate>Sat, 28 Feb 2015 11:36:00 +0000</pubDate><atom:updated>2015-02-28T12:37:12.193+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">7 segments LCD</category><category domain="http://www.blogger.com/atom/ns#">7-seg LCD</category><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">HT1621</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">PDC1211</category><title>PDC1211: a 7 segments LCD</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;border-bottom: 1px solid #2288bb; margin-bottom: 1em; text-shadow: 2px 2px 2px #C0C0C0;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Abstract&lt;/span&gt;&lt;br /&gt;
The PDC1211 is a 7-segments display LCD. In this post we provide a library for
dealing with this display. The library is strongly inspired by the classical
LiquidCrystal library.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;border-bottom: 1px solid #2288bb; margin-bottom: 1em;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Main Characteristics&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-size: -1; width: 600px;&quot;&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Module size (WxH):&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
95.6 x 32.6 mm&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Active area (W x H):&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
77.4 x 16.8 mm&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Viewing angle:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
6:00&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Driving voltage:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
5V&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Driving IC:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
HT1621&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Operating temp.:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
-2O°C to 60°C&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Storage temp.:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
-30°C to 70°C&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: semi-bold; padding-left: 10px; width: 10em;&quot;&gt;
Manifacturer:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
Nanjing Guoxian Electronics Corp&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQceVWqt0YseqpllLyX3Xx6Ku2IS6CA5XSYq5yDF2D1O7zr8egkEzpnyx4trWRvjH6q-WixNTghWWG729UbxX21xSDBYgh8_dXA9g7o_eg3NXFcFNWLCO13UihT1ZnpJpnraVNUtbNyxk/s1600/PDC1211-pinout-and-special.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQceVWqt0YseqpllLyX3Xx6Ku2IS6CA5XSYq5yDF2D1O7zr8egkEzpnyx4trWRvjH6q-WixNTghWWG729UbxX21xSDBYgh8_dXA9g7o_eg3NXFcFNWLCO13UihT1ZnpJpnraVNUtbNyxk/s1600/PDC1211-pinout-and-special.png&quot; height=&quot;209&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. PDC1211: special symbols and pinout.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Introduction&lt;/span&gt;
&lt;br /&gt;
The PDC1211 is a 7 segments LCD which is (was?) used mainly for telephony purposes.
It has 12 7-segments digits and 7 special symbols. Figure 1 provides an overall view of the display and the position of the special symbols (numbered 1 to 7 in red). Indeed, more than symbols these seems to be sentences written in Chinese. Since I don&#39;t know Chinese, I have no idea of their meaning. Except for the 4th one which I got translated from a Chineese girl that I met in the train: &quot;Local phone (number)&quot;. I would be grateful to any of you that could provide a translation for the remaining symbols/sentences.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Encoding a character&lt;/span&gt;
&lt;br /&gt;
Concerning the representation of the digits, the PDC1211 follows the requirements of the HT1211 chip. Figure 2 shows the wiring of the backpane and Figure 3 the wiring of the frontpane. These are useful to compute the code values for the printable characters.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit-WyjKA18br6h-Xyay_NXITDMuDgKfxcOYg0zq9qg8TX4zlIFpbUADoAgUtEm8t04z2567AYJ-1dc2iXapP0T81eF_zRsDncUcLtwDdqc8fOEN4r46WsPkBZiOLfCMF7ZhAQIz5Hdqsg/s1600/PDC1211-backpane-wiring.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit-WyjKA18br6h-Xyay_NXITDMuDgKfxcOYg0zq9qg8TX4zlIFpbUADoAgUtEm8t04z2567AYJ-1dc2iXapP0T81eF_zRsDncUcLtwDdqc8fOEN4r46WsPkBZiOLfCMF7ZhAQIz5Hdqsg/s1600/PDC1211-backpane-wiring.png&quot; height=&quot;201&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 2. Wiring of the backpane.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWsjFjhFM8IMZ3lp2kote7H0nh12sIkAOFfQLZIdK4kXWuRP5UUH4hNzRBrJP7oAJYIAXWYW_oniaq-wNH6PiMrbX-KIZ6MulBCZgUY9FeK4chr91NIWtb4-2oSXJRn8A2r9q4wO2DjV0/s1600/PDC1211-frontpane-wiring.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWsjFjhFM8IMZ3lp2kote7H0nh12sIkAOFfQLZIdK4kXWuRP5UUH4hNzRBrJP7oAJYIAXWYW_oniaq-wNH6PiMrbX-KIZ6MulBCZgUY9FeK4chr91NIWtb4-2oSXJRn8A2r9q4wO2DjV0/s1600/PDC1211-frontpane-wiring.png&quot; height=&quot;320&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 3. Wiring of the frontpne.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
Segment 0 of the memory mapping of the HT1621 corresponds to the leftmost digit. As illustrated in Figure 3, two memory segment adresses are used to encode a single character. Segments named a, b, c, d are the least significant bits and e, f, g, h. So to encode a 0 for example, one would set segments b, c, d in the first address and e, f, h in the other. Hence we obtain 0xE (or 0B1110) for the first segment and 0xB for the second. However, it is not recommended to write directly these values to the HT1621 but pass either through the &lt;code&gt;write&lt;/code&gt; function or through the standard &lt;code&gt;Print&lt;/code&gt; interface (see the dedicated section).
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Configuration&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;padding-left:10px&quot;&gt;
&lt;b&gt;Libraries.&lt;/b&gt; In order to work this library needs the following libraries installed:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://macduino.blogspot.com/2015/02/HT1621.html&quot;&gt;HT1621&lt;/a&gt; (version 1.0 or later)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://macduino.blogspot.com/2015/02/LiquidCrystal7S.html&quot;&gt;LiquidCrystal7S&lt;/a&gt; (version 1.1 or later)&lt;/li&gt;
&lt;/ul&gt;
both of them can be downloaded from this website.
&lt;br /&gt;
&lt;b&gt;Pinout.&lt;/b&gt; The pins on the module are numbered 1 (leftmost) to 5 (rightmost) and are associated as in Figure 1 where SS is pin 1 and Vcc is the number 5. In our examples, pin 1 is connected to Arduino pin 2, pin 2 to Arduino pin 3 and pin 3 to Arduino pin 4.
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Installing the library&lt;/span&gt;
&lt;br /&gt;
As all Arduino&#39;s additional libraries, PDC1211 has to be installed in your local Arduino&#39;s library directory (look into Preference pane of your Arduino IDE to discover the path) in a directory called PDC1211/src. The documentation can be installed into PDC1211/doc.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Communication protocol&lt;/span&gt;
&lt;br /&gt;
The communication between Arduino and the PDC1211 follows the same protocol as for the HT1621 but here Read/Write signals are on the same pin (RW) (see the documentation 
&lt;a href=&quot;http://macduino.blogspot.com/2015/02/HT1621.html&quot;&gt;here&lt;/a&gt; for more details).
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;The print interface&lt;/span&gt;
&lt;br /&gt;
This library implements the method of the &lt;a href=&quot;http://arduino.cc/en/Serial/Print&quot;&gt;Print&lt;/a&gt; interface of LiquidCrystal with all its advantages and all of its drawbacks. Moreover, remark that the type of the value to print is important, for example the following instructions all have the same effect of printing a &#39;0&#39; symbol on the LCD
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;lcd.print((&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;char&lt;/span&gt;)&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0xBE&lt;/span&gt;);
lcd.print(&lt;span style=&quot;color: #0044DD&quot;&gt;&amp;#39;0&amp;#39;&lt;/span&gt;);
lcd.print(&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt;);
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
while the following
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;lcd.print(&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0xBE&lt;/span&gt;);
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
will print a three character string &quot;190&quot; ie. the integer value of 0xBE.
&lt;br /&gt;
Finally, since this is a 7 segments display and hence not all characters can be displayed. The set of displayable characters is reduced to: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, b, C, c, d, E, F, H, h, L, N, n, o, P, r, t, U, u, -, . and space.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;
The examples&lt;/span&gt;
&lt;br /&gt;
The following snippet shows the typical usage of the library
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;// mandatory include files&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;HT1621.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;LiquidCrystal7S.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;PDC1211.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// Pin connections &lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define SS 2&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define RW 3&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define DATA 4&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;// LCD class instantiation&lt;/span&gt;
PDC1211 &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;lcd&lt;/span&gt;(SS,RW,DATA);
&lt;div style=&quot;line-height:.1em&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {
  ...
  lcd.begin();
  ...
}
&lt;div style=&quot;line-height:.1em&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {
    ...
    
    lcd.print(&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;HELLO&amp;quot;&lt;/span&gt;); &lt;span style=&quot;color: #888888&quot;&gt;// print something&lt;/span&gt;
    ...
}
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
All the examples shipped with LiquidCrystal library run as well exception made, of course, for those implying unsupported methods (see section next section).
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #2288bb;font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Supported LiquidCrystal methods&lt;/span&gt;
&lt;br /&gt;
Since PDC1211 is a child class of the LiquidCrystal7S class, it supports all of the methods of this class. However, they are a subset of those implemented by the LiquidCrystal library since they are impossible to implement in the context of a 7 segments display. Here is the full list of the unsupported methods:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cursor()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;noCursor()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;blink()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;noBlink()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;createChar()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;blink()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;noBlink()&lt;/code&gt;
&lt;li&gt;&lt;code&gt;createChar()&lt;/code&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: semi-bold;&quot;&gt;Downloads&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
The library consists in only one header and an implementation files:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_OGxEOHFMcEpSZm8/view?usp=sharing&quot;&gt;PDC1211.h&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_T2RsU21BQzlYdkU/view?usp=sharing&quot;&gt;PDC1211.cpp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
And here it is the documentation both in pdf and html (zipped) formats:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_ZllmaXF5OEczTUE/view?usp=sharing&quot;&gt;PDC1211-man-v1_0.pdf&lt;/a&gt; (pdf format)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_dWlUVDBZMWRKXzA/view?usp=sharing&quot;&gt;PDC1211-man-v1_0.zip&lt;/a&gt; (html format)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #2288bb;font-weight:semi-bold&quot;&gt;Enjoy!&lt;/span&gt;</description><link>https://macduino.blogspot.com/2015/02/pdc1211.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQceVWqt0YseqpllLyX3Xx6Ku2IS6CA5XSYq5yDF2D1O7zr8egkEzpnyx4trWRvjH6q-WixNTghWWG729UbxX21xSDBYgh8_dXA9g7o_eg3NXFcFNWLCO13UihT1ZnpJpnraVNUtbNyxk/s72-c/PDC1211-pinout-and-special.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-965147121112232370</guid><pubDate>Sun, 15 Feb 2015 11:20:00 +0000</pubDate><atom:updated>2018-04-16T02:07:10.536+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">7 segments LCD</category><category domain="http://www.blogger.com/atom/ns#">7-seg LCD</category><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">HT1621</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><title>LiquidCrystal7S: a library for 7 segments LCD based on HT1621 chipset</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Abstract&lt;/h4&gt;
This project aims at implementing the same functionalities as the classical LiquidCrystal library for 7 segments LCD based on the HT1621 chipset. The LCD is supposed to communicate with the HT1621 through a 3-wire or a 4-wire serial protocol. Remark that
this wants to be a generic driver, hence only the basic features of 7 segments displays are implemented. All the other features such as displaying special characters or fine tuning should be implemented in a child class. Indeed, the driver is not aware of how memory is mapped to the LCD screen.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Configuration&lt;/h4&gt;
&lt;span style=&quot;font-style: italic; padding-right: 10px;&quot;&gt;LCD initialization.&lt;/span&gt;The display is initialized with 256KHz internal RC clock frequency, 1/3 Bias and 4 Commons. Refer to the manual of class HT1621
on how to change these settings.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-style: italic; padding-right: 10px;&quot;&gt;Communication protocol.&lt;/span&gt;
The communication protocol (3-Wire vs. 4-Wire) is chosen at the constructor level. Using the k-parameters constructor selects the k-Wire protocol.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
The examples&lt;/h4&gt;
As usual, here is a small example for testing the library. The sketch initializes the
LCD and then writes a line of symbols 0xBE (this corresponds to &#39;0&#39; on my LCD). The
sketch assumes a 12 digits LCD, if you has more (or less) digits please modify the range
in the &lt;code&gt;for&lt;/code&gt; loop.
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid #e0efef; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \file LiquidCrystal7S-test.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \brief Simple test sketch for the LiquidCrystal7S library.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \date 8 february 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;HT1621.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;LiquidCrystal7S.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;// refer to Macduino website for pin connections &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// and their meaning&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define SS 2&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define RW 3&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define DATA 4&lt;/span&gt;

LiquidCrystal7S &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;lcd&lt;/span&gt;(SS,RW,DATA);

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; i;
  
  lcd.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;12&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;);

  &lt;span style=&quot;color: #888888;&quot;&gt;// write all zeroes&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;12&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;)  
    lcd.print((&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;char&lt;/span&gt;)&lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0xBE&lt;/span&gt;); &lt;span style=&quot;color: #888888;&quot;&gt;// remark the cast here&lt;/span&gt;
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
As a second example, here is a sketch which prints a string of three characters
&lt;code&gt;0xBE&lt;/code&gt; (a &#39;0&#39; on my LCD).
&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid #e0efef; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \file LiquidCrystal7S-test.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \brief Print a string using LiquidCrystal7S library.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \date 8 february 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;HT1621.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;LiquidCrystal7S.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;// refer to Macduino website for pin connections &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// and their meaning&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define SS 2&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define RW 3&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define DATA 4&lt;/span&gt;

LiquidCrystal7S &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;lcd&lt;/span&gt;(SS,RW,DATA);
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;char&lt;/span&gt; str[] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; {&lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0xBE&lt;/span&gt;, &lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0xBE&lt;/span&gt;, &lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0xBE&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;};

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  
  lcd.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;12&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;);

  &lt;span style=&quot;color: #888888;&quot;&gt;// write 3 zeroes&lt;/span&gt;
  lcd.print(str); &lt;span style=&quot;color: #888888;&quot;&gt;// remark the definition of str here&lt;/span&gt;
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Downloads&lt;/h4&gt;
The library consists just in the header and implementations files:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_R25YTjQ2R3pyQkU/view?usp=sharing&quot;&gt;LiquidCrystal7S.h&lt;/a&gt; (ver. 1.11)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_SUxqR1NvU19xTDA/view?usp=sharing&quot;&gt;LiquidCrystal7S.cpp&lt;/a&gt; (ver. 1.11)&lt;/li&gt;
&lt;/ul&gt;
The documentation is provided both in html and pdf formats:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_Q3dPNHVKWEFyU2M/view?usp=sharing&quot;&gt;LiquidCrystal7S-man-v1_11.pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_OXlZT2huQkp5Yjg/view?usp=sharing&quot;&gt;LiquidCrystal7S-man-v1_11-html.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
See also&lt;/h4&gt;
&lt;a href=&quot;https://macduino.blogspot.com/2015/02/HT1621.html&quot;&gt;HT1621: a seven segments LCD driver&lt;/a&gt;
&lt;/div&gt;
</description><link>https://macduino.blogspot.com/2015/02/LiquidCrystal7S.html</link><author>noreply@blogger.com (Maczinga)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-5093984152145068374</guid><pubDate>Wed, 11 Feb 2015 23:41:00 +0000</pubDate><atom:updated>2015-02-15T12:22:48.027+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">HC-SR04</category><category domain="http://www.blogger.com/atom/ns#">motion detection</category><category domain="http://www.blogger.com/atom/ns#">Passive Infrared sensor</category><category domain="http://www.blogger.com/atom/ns#">PIR sensor</category><category domain="http://www.blogger.com/atom/ns#">Ultrasonic sensor</category><category domain="http://www.blogger.com/atom/ns#">US-020</category><title>HC-SR04 : using an ultrasonic module as a motion detector</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Abstract&lt;/h4&gt;
This week we are going to use our preferred ultrasonic sensor as a motion detection module. This is an alternative to the classical PIR sensors (see &lt;a href=&quot;http://macduino.blogspot.com/2013/11/PIR-sensor.html&quot;&gt;here&lt;/a&gt;) with its pros and contras that we will try to illustrate.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
The idea&lt;/h4&gt;
We are going to use the HC-SR04 to measure some default distance (background distance) B. At regular time frames we are
going to measure a new distance, say D. If D is different from A, then this means that there is an obstacle between the
sonar and B. 
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Computing the background distance&lt;/h4&gt;
We assume that the sensor has been fixed on some support and that for a certain interval of time there are no objects
that enter in the scene. From &lt;a href=&quot;http://macduino.blogspot.com/2013/12/HC-SR04-avoiding-oversampling.html&quot;&gt;this&lt;/a&gt; post, the safe interval of
times between two distinct distance measurements is 26ms. Therefore we are going to perform &lt;code&gt;SAMPLESIZE&lt;/code&gt; measurements and take the average distance (rounded up) as background distance.
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid #e0efef; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;SetupDefaultDistance&lt;/span&gt;() {
  
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint64_t&lt;/span&gt; averageMillis;
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint32_t&lt;/span&gt; i;

  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;, averageMillis&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;SAMPLESIZE; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;) {
    averageMillis &lt;span style=&quot;color: #333333;&quot;&gt;+=&lt;/span&gt; readoutSensor();
    delay(INITDELAYMS);
  }
 
  &lt;span style=&quot;color: #888888;&quot;&gt;// return the mean (rounded up)&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt;)(averageMillis&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;SAMPLESIZE); 
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Configuring the sketch&lt;/h4&gt;
&lt;span style=&quot;font-style: italic; padding-right: 12px;&quot;&gt;Using a different ultrasonic module.&lt;/span&gt;
To configure the sketch for a different ultrasonic module, the
just change the definition of INITDELAYMS which is the minimal
time between two valid distance measurements. The duration of the
trigger signal is configured by changing TRIGLENUS (expressed in
microseconds).&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-style: italic; padding-right: 12px;&quot;&gt;Choosing sample size.&lt;/span&gt;
The duration and precision of the computation of the calibration phase is regulated
by the macro &lt;code&gt;SAMPLESIZE&lt;/code&gt; which accounts for the number of measurements
over which take the mean distance (ie the background distance). Of course, the
larger this number the more precise will be the value of the background distance.
However, remark that larger sample sizes require greater times to be computed.
We think that setting it to 100 is a good trade-off.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-style: italic; padding-right: 12px;&quot;&gt;Sensibility.&lt;/span&gt;
As it is well-known, the measurements of our sensor are not perfect. Therefore, if we
don&#39;t want to trigger alarm just because a measuring error, it is better to setup
some tolerance for measurement errors. Tolerance is controlled by the macro &lt;code&gt;
TOLERANCE&lt;/code&gt; which contains a float number between 0 and 1 which stands for the
percentage of errors that we accept. Of course, it is not wise to setup a tolerance
which is lower than your sensor precision ;-)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-style: italic; padding-right: 12px;&quot;&gt;The pinout.&lt;/span&gt;
The sketch uses digital pins 2 (ECHO signal) and 4 (TRIGGER signal). 
If one needs to change them, just change the corresponding macro definitions
&lt;code&gt;TRIGPIN&lt;/code&gt; and &lt;code&gt;ECHOPIN&lt;/code&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
The complete sketch&lt;/h4&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid #e0efef; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \file MotionDetection.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \brief Motion detection using an HC-SR04&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \date 9 february 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;// the include below is for old versions of the IDE&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// #include &amp;lt;Serial.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define SAMPLESIZE 100&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TOLERANCE .01&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define INITDELAYMS 26&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TRIGLENUS 10&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;// trigger pin of HC-SR04&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TRIGPIN 4 &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// echo pin of HC-SR04&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define ECHOPIN 2&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; defaultMS;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; curMillis;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; millisTolerance;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;readoutSensor&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888;&quot;&gt;// The sensor is triggered by a HIGH pulse of 10us or more.&lt;/span&gt;
  &lt;span style=&quot;color: #888888;&quot;&gt;// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:&lt;/span&gt;
  digitalWrite(TRIGPIN, LOW);
  delayMicroseconds(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;);

  &lt;span style=&quot;color: #888888;&quot;&gt;// Start trigger signal&lt;/span&gt;

  digitalWrite(TRIGPIN, HIGH);
  delayMicroseconds(TRIGLENUS);
  digitalWrite(TRIGPIN, LOW);
 
  &lt;span style=&quot;color: #888888;&quot;&gt;// Read the signal from the sensor: a HIGH pulse whose&lt;/span&gt;
  &lt;span style=&quot;color: #888888;&quot;&gt;// duration is the time (in microseconds) from the sending&lt;/span&gt;
  &lt;span style=&quot;color: #888888;&quot;&gt;// of the ping to the reception of its echo off of an object.&lt;/span&gt;
 
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; pulseIn(ECHOPIN, HIGH);
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;SetupDefaultDistance&lt;/span&gt;() {
  
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint64_t&lt;/span&gt; averageMillis;
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint32_t&lt;/span&gt; i;

  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;, averageMillis &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;SAMPLESIZE; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;) {
    averageMillis &lt;span style=&quot;color: #333333;&quot;&gt;+=&lt;/span&gt; readoutSensor();
    delay(INITDELAYMS);
  }
 
  &lt;span style=&quot;color: #888888;&quot;&gt;// return the mean (rounded up)&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt;)(averageMillis&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;SAMPLESIZE); 
}



&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {

  &lt;span style=&quot;color: #888888;&quot;&gt;// setup pins&lt;/span&gt;
  pinMode(TRIGPIN, OUTPUT);
  pinMode(ECHOPIN, INPUT);

  &lt;span style=&quot;color: #888888;&quot;&gt;// init serial communication&lt;/span&gt;
  Serial.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;9600&lt;/span&gt;);

  &lt;span style=&quot;color: #888888;&quot;&gt;// compute background distance&lt;/span&gt;
  Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Computing defaults...&quot;&lt;/span&gt;);

  defaultMS &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; SetupDefaultDistance();
  millisTolerance &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt;)(defaultMS &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; TOLERANCE);
  
  Serial.println(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Done.&quot;&lt;/span&gt;); 
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; val;
  
  curMillis &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; readoutSensor();

  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt; ( curMillis&lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&lt;/span&gt;defaultMS) 
    val &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; curMillis&lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt;defaultMS;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt;
    val &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; defaultMS &lt;span style=&quot;color: #333333;&quot;&gt;-&lt;/span&gt; curMillis;
        
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;( val &lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&lt;/span&gt; millisTolerance)
    Serial.println(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Motion detected!&quot;&lt;/span&gt;);
 
  delay(INITDELAYMS);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Remark that in the sketch all the distances etc. are expressend in milliseconds since there
is no point to transform them into real distance. Indeed, we just want to measure differences!&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Detection failures&lt;/h4&gt;
If an object runs through the sensing cone of the HC-SR04 fast enough, then the sensor
may fail to detect it. Indeed, assume that the sensing cone is 30 degrees wide (horizontally) and that an object traverses the cone at some distance &lt;code&gt;d&lt;/code&gt;
in a direction which is parallel to the sensor as illustrated in Figure 1. The HC-SR04 is positioned at the bottom of the triangle.&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHEJ3y3QpTJ1PYTZJoyy15L5EgX4dsPYJejZJ42IbETmVNQ59IHwWXJakVZa4BYHkqVRqVj5H7bVmuu9IVrOMmvpfECmYtjeT6bmtRQWIM7uCEFBqnHLFAGr3L-0L97bK9E0EaXMoiRCs/s1600/failure.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHEJ3y3QpTJ1PYTZJoyy15L5EgX4dsPYJejZJ42IbETmVNQ59IHwWXJakVZa4BYHkqVRqVj5H7bVmuu9IVrOMmvpfECmYtjeT6bmtRQWIM7uCEFBqnHLFAGr3L-0L97bK9E0EaXMoiRCs/s1600/failure.png&quot; height=&quot;212&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fig. 1. Example of detection failure.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Then, with simple trigonometric calculations we may find that the speed &lt;code&gt;v&lt;/code&gt; is
given by the formula given in Figure 1, where &lt;code&gt;t&lt;sub&gt;d&lt;/sub&gt;&lt;/code&gt; is the time that takes the sound wave emitted by the HC-SR04 to travel the distance &lt;code&gt;d&lt;/code&gt;.
For example, if &lt;code&gt;d=4m&lt;/code&gt; then &lt;code&gt;v&lt;/code&gt; is about 91 m/s.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
HC-SR04 vs. PIR sensor&lt;/h4&gt;
Each of these two modules has its own precise purpose which is distance measuring for HC-SR04 and motion detection for a PIR sensor. It is pretty clear that a PIR sensor cannot
be used for distance measuring; however, an HC-SR04 can be used as a motion detector as
it is proved by our previous sketch. Let us try to list advantages and disadvantages.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-style: italic;&quot;&gt;Advantages&lt;/span&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Multipurpose: the HC-SR04 can be reverted for measuring distances; then back to
motion detection and so on.&lt;/li&gt;
&lt;li&gt;Configuration: the HC-SR04 can be quickly reconfigured completely via software; while, in general, PIR sensors need manual hardware configuration.&lt;/li&gt;
&lt;li&gt;Initialization: can be pretty fast on the HC-SR04 (2-3 seconds); while it is
a least 10 seconds on most PIR sensors.&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-style: italic;&quot;&gt;Disadvantages&lt;/span&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Sensing cone: PIR sensors have large sensing cones while the cone of HC-SR04 is very few degrees wide vertically and less than 30 degrees horizontally.&lt;/li&gt;
&lt;li&gt;Speed: of course, light speed (PIR sensor) is incomparably higher than sound speed
(HC-SR04).&lt;/li&gt;
&lt;li&gt;CPU usage: the HC-SR04 needs to send signals periodically in order to detect motion and this uses CPU of course. On the other hand, PIR sensors are passive sensors, so they need CPU only when a motion is detected (if they are attached to an interrupt).&lt;/li&gt;
&lt;li&gt;Detection failures: because of its low speed, the HC-SR04 may fail to detect a fast enough moving object (see the dedicated section); while this is nearly impossible for PIR sensors.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;See also&lt;/h4&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/12/HC-SR04-avoiding-oversampling.html&quot;&gt;
HC-SR04: avoiding oversampling errors&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/12/HC-SR04-dist-law-of-values-part2.html&quot;&gt;
HC-SR04: what is the distribution law for the frequencies of values? (Part 2)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/12/HC-SR04-dist-law-of-values.html&quot;&gt;
HC-SR04: what is the distribution law for the frequencies of values? (Part 1)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/11/hc-sr04-using-multiple-ultrasonic.html&quot;&gt;
HC-SR04 : using multiple ultrasonic modules&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2013/11/HC-SR04-part1.html&quot;&gt;Introduction to HC-SR04&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Conclusions&lt;/h4&gt;
Each module is designed for its own purpose. However, turning an HC-SR04 into a motion
detector can be useful in some situations.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
Enjoy!&lt;/h4&gt;</description><link>https://macduino.blogspot.com/2015/02/hc-sr04-motion-detection.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHEJ3y3QpTJ1PYTZJoyy15L5EgX4dsPYJejZJ42IbETmVNQ59IHwWXJakVZa4BYHkqVRqVj5H7bVmuu9IVrOMmvpfECmYtjeT6bmtRQWIM7uCEFBqnHLFAGr3L-0L97bK9E0EaXMoiRCs/s72-c/failure.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-7319281620094672792</guid><pubDate>Fri, 06 Feb 2015 22:11:00 +0000</pubDate><atom:updated>2016-09-10T13:31:09.498+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">7 segments LCD</category><category domain="http://www.blogger.com/atom/ns#">7-seg LCD</category><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">Datasheet</category><category domain="http://www.blogger.com/atom/ns#">HT1621</category><title>HT1621: a seven segments LCD driver</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;border-bottom: 1px solid #2288bb; margin-bottom: 1em;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Abstract&lt;/span&gt;&lt;br /&gt;
This note resumes the main characteristics of the HT1621 chip that are useful to drive 7-segments displays on Arduino boards.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;border-bottom: 1px solid #2288bb; margin-bottom: 1em;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;height: 1em;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Main Characteristics&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-size: -1; width: 600px;&quot;&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Memory:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
32x4 bits RAM (i.e. enough for 32x 7-seg displays with dot)&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Operating voltage:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
2.4V-5.2V&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Power Consumption:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
&amp;lt;3mA (@5V)&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; visibility: hidden; width: 10em;&quot;&gt;
Power Consumption:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
&amp;lt;600μA (@5V with no load, LCD on, internal RC oscillator on)&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Clock (built-in):&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
256kHz RC oscillator&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Clock (external):&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
32kHz quartz oscillator or 256kHZ external input&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Comm. interface:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 25em;&quot;&gt;
3-wire serial interface&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;height: 1em;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Additional features&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-size: -1; width: 600px;&quot;&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Comm. interface:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
3-wire serial interface&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Tone buzzer:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
built-in 2kHz or 4kHz tone buzzer&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display: table-row;&quot;&gt;
&lt;div style=&quot;display: table-cell; font-weight: bold; padding-left: 10px; width: 10em;&quot;&gt;
Data accessing:&lt;/div&gt;
&lt;div style=&quot;border-bottom: 1px dotted #333; display: table-cell; font-size: 9pt; padding-top: 3px; text-align: left; width: 28em;&quot;&gt;
three accessing modes&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;height: 1.5em;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Block diagram&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em;&quot;&gt;
Here is the functional block diagram directly extracted from the Holtek datasheet. In the sequel we will describe each of these blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9DZCWCnlCHMhnmOMyJOqNAMst4DmWsq2TGg7kn6CE-yh2HlMnlUUQkm3O0v_hUFuwgv3zZFKl9P6O5SPU2zQUNwXm_CKo8F0_nOWW-6Fm7ZOmNXXFtN29WN5MeEOFZk5dPxx-Kk-YL84/s1600/HT1621-block-diagram.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9DZCWCnlCHMhnmOMyJOqNAMst4DmWsq2TGg7kn6CE-yh2HlMnlUUQkm3O0v_hUFuwgv3zZFKl9P6O5SPU2zQUNwXm_CKo8F0_nOWW-6Fm7ZOmNXXFtN29WN5MeEOFZk5dPxx-Kk-YL84/s1600/HT1621-block-diagram.png&quot; height=&quot;326&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. HT1621: functional block diagram.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;height: 1.5em;&quot;&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Display RAM&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This chip has a 32x4 bits static display RAM which is mapped directly to the display driver. Adresses are organized as displayed in Figure 2.&amp;nbsp;&lt;span class=&quot;s1&quot;&gt;The content of the RAM is directly mapped to the content of the LCD driver and may be affected by the commands &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;READ&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;WRITE&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;READ-MODIFY-WRITE&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uLvYapo7awvND1KliLkMLjfOoQmDoqqP6MsWhLTlu3KQd8FsLfr2wNjaOpfoKizeNibLT5N2cKEhr-iha3K3Besx4XoGbNF-msP6ggn66GMFmdUyHcO76nhHNR8_M5ZqrOsKwKZgrwU/s1600/HT1621mem.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-uLvYapo7awvND1KliLkMLjfOoQmDoqqP6MsWhLTlu3KQd8FsLfr2wNjaOpfoKizeNibLT5N2cKEhr-iha3K3Besx4XoGbNF-msP6ggn66GMFmdUyHcO76nhHNR8_M5ZqrOsKwKZgrwU/s1600/HT1621mem.png&quot; height=&quot;320&quot; width=&quot;264&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;Figure 1. Memory structure of the HT1621. Remark that we have&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;restructure the&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;s1&quot; style=&quot;font-size: 12.8000001907349px;&quot;&gt;adresses so to be able&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 12.8000001907349px;&quot;&gt;to take care of a full digit.&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;System oscillator&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
The system clock is used in a variety of tasks included LCD driving clock and tone frequency generation.
HT1621 has a built-in RC oscillator (256kHZ) and a crystal oscillator (32768Hz). An external 256KHz
oscillator can also be used. The type of oscillator used can be selecting by issuing XTAL32K,
RC256K or EXT256K commands.
&lt;br /&gt;
Issuing a SYS_DIS command stops the system clock, the LCD bias generator and the time base/WDT.
The LCD screen will appear blank.
An LCD_OFF command will turn off the bias generator but not the system clock. Issuing a
SYS_DIS command will power down the system reducing power consumption.&lt;br /&gt;
&lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;Warning:&lt;/span&gt;
The SYS_DIS command affects the system only when the internal RC 256kHZ or the 32.768kHz crystal clocks are used.
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Tone output&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify;&quot;&gt;
The HT1621 can provide a tone output at the pins BZ and &lt;u&gt;BZ&lt;/u&gt;. There are only two tone
frequencies, namely: 2kHz and 4kHz that can be selected using the TONE2K or TONE4K, respectively.
Then, the buzzer (if connected to BZ and &lt;u&gt;BZ&lt;/u&gt;) start playing at the
TONE_ON command. Sound is stopped issuing the TONE_OFF command.
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Power-on&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
At power-on the system is in &lt;code&gt;SYS_DIS&lt;/code&gt; state. A generic LCD initialization sequence will consist of the following steps:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Oscillator configuration&lt;/li&gt;
&lt;li&gt;Bias/com configuration&lt;/li&gt;
&lt;li&gt;System Enable&lt;/li&gt;
&lt;li&gt;Bias generator start (LCD_ON)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;The library&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
We have written a library to deal with all the features of HT1621. Since we could test the HT1621 only through a LCD
which did not allow to read the on-chip RAM. We provide procedures to software simulate the internal HT1621 internal
RAM and have transparent reading procedures. The simulated RAM is used as a default. To change this and use internal
HT1621 RAM you need to add 
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;code&gt;#define __HT1621_READ&lt;/code&gt;&lt;/div&gt;
right before including the library header file in your sketch.
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;The test sketch&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
We provide a very basic sketch for testing the main functions. The pins are connected as follows:
&lt;style&gt;
.CSSTableGenerator {
 margin:0px auto;padding:10px auto auto auto;
 width:300px;
 box-shadow: 8px 8px 5px #888888;
 border:1px solid #000000;
 
 -moz-border-radius-bottomleft:10px;
 -webkit-border-bottom-left-radius:10px;
 border-bottom-left-radius:10px;
 
 -moz-border-radius-bottomright:10px;
 -webkit-border-bottom-right-radius:10px;
 border-bottom-right-radius:10px;
 
 -moz-border-radius-topright:10px;
 -webkit-border-top-right-radius:10px;
 border-top-right-radius:10px;
 
 -moz-border-radius-topleft:10px;
 -webkit-border-top-left-radius:10px;
 border-top-left-radius:10px;
}.CSSTableGenerator table{
    border-collapse: collapse;
        border-spacing: 0;
 width:100%;
 height:100%;
 margin:0px;padding:0px;
}.CSSTableGenerator tr:last-child td:last-child {
 -moz-border-radius-bottomright:10px;
 -webkit-border-bottom-right-radius:10px;
 border-bottom-right-radius:10px;
}
.CSSTableGenerator table tr:first-child td:first-child {
 -moz-border-radius-topleft:10px;
 -webkit-border-top-left-radius:10px;
 border-top-left-radius:10px;
}
.CSSTableGenerator table tr:first-child td:last-child {
 -moz-border-radius-topright:10px;
 -webkit-border-top-right-radius:10px;
 border-top-right-radius:10px;
}.CSSTableGenerator tr:last-child td:first-child{
 -moz-border-radius-bottomleft:10px;
 -webkit-border-bottom-left-radius:10px;
 border-bottom-left-radius:10px;
}.CSSTableGenerator tr:hover td{
 
}
.CSSTableGenerator tr:nth-child(odd){ background-color:#ffd4aa; }
.CSSTableGenerator tr:nth-child(even)    { background-color:#ffffff; }.CSSTableGenerator td{
 vertical-align:middle;
 
 
 border:1px solid #000000;
 border-width:0px 1px 1px 0px;
 text-align:left;
 padding:7px;
 font-size:10px;
 font-family:Arial;
 font-weight:bold;
 color:#000000;
}.CSSTableGenerator tr:last-child td{
 border-width:0px 1px 0px 0px;
}.CSSTableGenerator tr td:last-child{
 border-width:0px 0px 1px 0px;
}.CSSTableGenerator tr:last-child td:last-child{
 border-width:0px 0px 0px 0px;
}
.CSSTableGenerator tr:first-child td{
  background:-o-linear-gradient(bottom, #ff7f00 5%, #bf5f00 100%); background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #bf5f00) );
 background:-moz-linear-gradient( center top, #ff7f00 5%, #bf5f00 100% );
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=&quot;#ff7f00&quot;, endColorstr=&quot;#bf5f00&quot;); background: -o-linear-gradient(top,#ff7f00,bf5f00);

 background-color:#ff7f00;
 border:0px solid #000000;
 text-align:center;
 border-width:0px 0px 1px 1px;
 font-size:14px;
 font-family:Arial;
 font-weight:bold;
 color:#ffffff;
}
.CSSTableGenerator tr:first-child:hover td{
 background:-o-linear-gradient(bottom, #ff7f00 5%, #bf5f00 100%); background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #bf5f00) );
 background:-moz-linear-gradient( center top, #ff7f00 5%, #bf5f00 100% );
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=&quot;#ff7f00&quot;, endColorstr=&quot;#bf5f00&quot;); background: -o-linear-gradient(top,#ff7f00,bf5f00);

 background-color:#ff7f00;
}
.CSSTableGenerator tr:first-child td:first-child{
 border-width:0px 0px 1px 0px;
}
.CSSTableGenerator tr:first-child td:last-child{
 border-width:0px 0px 1px 1px;
}
&lt;/style&gt;
&lt;br /&gt;
&lt;div class=&quot;CSSTableGenerator&quot;&gt;
   &lt;table &gt;
     &lt;tr&gt; 
       &lt;td&gt;HT1621&lt;/td&gt;
       &lt;td &gt;Arduino&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
       &lt;td&gt;SS&lt;/td&gt;
       &lt;td&gt;2&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
       &lt;td&gt;R/W&lt;/td&gt;
       &lt;td&gt;3&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
       &lt;td &gt;DATA&lt;/td&gt;
       &lt;td&gt;4&lt;/td&gt;
     &lt;/tr&gt;
   &lt;/table&gt;
&lt;/div&gt;
&lt;/br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \file HT1621-test.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \brief Simple test sketch for the HT1621 class.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \date 4 february 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;HT1621.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #888888&quot;&gt;// refere to Macduino website for pin connections and their meaning&lt;/span&gt;
HT1621 &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;ht&lt;/span&gt;(&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;4&lt;/span&gt;);

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {

  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i;
  
  ht.begin();
  
  ht.sendCommand(HT1621&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;RC256K);
  ht.sendCommand(HT1621&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;BIAS_THIRD_4_COM);
  ht.sendCommand(HT1621&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;SYS_EN);
  ht.sendCommand(HT1621&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;LCD_ON);

  &lt;span style=&quot;color: #888888&quot;&gt;// clear memory&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;16&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
    ht.write(i,&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;);

  &lt;span style=&quot;color: #888888&quot;&gt;// write all zeroes&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;16&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)  
    ht.write(i, &lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0xBE&lt;/span&gt;);
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {}
&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
A more comprehensive test set will come with the
next post.


&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Downloads&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
The library consists in only one header and an implementation files:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_TjBpZENkd3AzYjQ/view?usp=sharing&quot;&gt;HT1621.h&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_SzhBWEUxZXJ3d1U/view?usp=sharing&quot;&gt;HT1621.cpp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
And here it is the documentation both in pdf and html (zipped) formats:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_QVZocG9zYlc5NDg/view?usp=sharing&quot;&gt;HT1621-v1-doc.pdf&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_Zmp5cTh4dzN1cU0/view?usp=sharing&quot;&gt;HT1621-v1-doc-html.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Datasheets and application notes&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
And here it is the datasheets and application notes taken directly from Holtek
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_WUZDbk5HbHZFZ0k/view?usp=sharing&quot;&gt;Holtek HT1621&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_SXdQWWpGZFBvZWc/view?usp=sharing&quot;&gt;Using C-language and the HT48 &amp; HT46 MCU to Read/Write to the HT1621&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_RmViNXkxMmJ3NUk/view?usp=sharing&quot;&gt;Controlling the HT1621 LCD Controller With the HT48 MCU Series&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;border-bottom: 1px solid #2288bb; font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;What&#39;s next&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: &#39;Times-new-roman&#39;, serif; font-size: normal; padding-left: 10px; padding-top: .5em; text-align: justify; text-align: justify;&quot;&gt;
In the next post we will provide a class for dealing with a generic 7-segments LCD module based on the HT1621 chip with instruction
set similar to the classical LiquidCrystal library (&lt;a href=&quot;http://macduino.blogspot.com/2015/02/LiquidCrystal7S.html&quot;&gt;here&lt;/a&gt;). Finally, a class for a specific 7-seg LCD module that I found at
bargains.
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Oswald&#39;, sans-serif; font-weight: bold;&quot;&gt;Enjoy!&lt;/span&gt;</description><link>https://macduino.blogspot.com/2015/02/HT1621.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9DZCWCnlCHMhnmOMyJOqNAMst4DmWsq2TGg7kn6CE-yh2HlMnlUUQkm3O0v_hUFuwgv3zZFKl9P6O5SPU2zQUNwXm_CKo8F0_nOWW-6Fm7ZOmNXXFtN29WN5MeEOFZk5dPxx-Kk-YL84/s72-c/HT1621-block-diagram.png" height="72" width="72"/><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-239041994378135065</guid><pubDate>Sun, 01 Feb 2015 21:24:00 +0000</pubDate><atom:updated>2015-02-06T23:11:50.616+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino FM Radio</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo module</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">MR007-005.1</category><category domain="http://www.blogger.com/atom/ns#">TEA5767</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HL</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HN</category><category domain="http://www.blogger.com/atom/ns#">TEA5768</category><category domain="http://www.blogger.com/atom/ns#">TEA5768HL</category><title>FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757)(Part 4/4)</title><description>&lt;div style=&quot;margin-left: auto; margin-right: auto; text-align: justify; width: 75%;&quot;&gt;
&lt;h4&gt;
Abstract&lt;/h4&gt;
In this last part we provide a basic front-end for the FM radio and a simple example program.
Moreover, we provide full documentation for all the TEA library and their classes.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This project is a simple implementation of a FM Radio player based on the FM module. The radio has a simple front-end consisting of the LCD module and its buttons. The are five possible working modes. For more details on the working modes see the Section  &quot;Using the radio&quot;.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;Building the radio&lt;/h4&gt;
Just stack the LCD module (more infos &lt;a href=&quot;http://macduino.blogspot.com/2013/11/basic-lcd-module.html&quot;&gt;here&lt;/a&gt;) on your Arduino and connect the FM module
as explained &lt;a href=&quot;http://macduino.blogspot.com/2015/01/TEA5767-TEA5768-FM-Module.html&quot;&gt;here&lt;/a&gt;. That&#39;s all!
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
Display and buttons&lt;/h4&gt;
In all working modes (except for the sub-modes) the information is displayed in a standard format on the LCD. The first line indicates the frequency of the current station being reproduced (approx to 2 decimal digits) and the current working mode. The second line displays the audio level (a number between 0 and 16) and if the reception is stereo or mono. The following figure gives a more visual illustration of the display organisation.
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzAPpnZOf-WkdmIVszSaeFPieK8tymAyOOjagg99dtcpC5BO6kJw7bl3Q0O5vwRYg9drkoGr7G_KJVFXE8zSI50-WJppfNyMqUsomDrWT40gH_D4aj0C75NA1wuJDr4cuyMNukmpCcm1I/s1600/LCD-Disp-Info-small.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzAPpnZOf-WkdmIVszSaeFPieK8tymAyOOjagg99dtcpC5BO6kJw7bl3Q0O5vwRYg9drkoGr7G_KJVFXE8zSI50-WJppfNyMqUsomDrWT40gH_D4aj0C75NA1wuJDr4cuyMNukmpCcm1I/s1600/LCD-Disp-Info-small.png&quot; height=&quot;249&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. Display organisation in main working modes.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
The radio uses 4 out the 5 buttons on the LCD module (the leftmost ones). The leftmost button (button 1) and the its neighbor (button 2) are used as navigation buttons. In standard mode (STD), they are used to search backward (resp. forward) for the next station to reproduce. In recording mode (REC) and in memory mode (MEM), they are used to move backward or forward in the memory array. Button 3 is called mode button and it is used to change the working mode. Button 4 is called action button and it is used to confirm actions for the current working mode. For example, when choosing a memory slot for memorizing the current station in the memory array, if this button is pressed then the frequency of the current station is recorded and the radio returns in STD mode. The following figure illustrates buttons positions.
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgHnKd43L8GrsHFPL0YiMeFKrL9NBeYC4blNm3FYbSXn2evAtMjTfg0LVWsXHb1NpwPfQCCgKFWVbx9YjHEFH1auTL9LC2pujoPShyphenhyphen9k29MYno9EldRNy4Wm346Eop6JKfnDfqoVlWatM/s1600/lcd-btns.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgHnKd43L8GrsHFPL0YiMeFKrL9NBeYC4blNm3FYbSXn2evAtMjTfg0LVWsXHb1NpwPfQCCgKFWVbx9YjHEFH1auTL9LC2pujoPShyphenhyphen9k29MYno9EldRNy4Wm346Eop6JKfnDfqoVlWatM/s1600/lcd-btns.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 2. Buttons of the LCD module.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;span style=&quot;font-weight:bold;color:red&quot;&gt;Warning&lt;/span&gt;
For lack of space when displaying information on the LCD, some shortcuts are used. For example, btn means &quot;button&quot; and act means &quot;action&quot;, etc.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;h4&gt;Using the radio&lt;/h4&gt;
At power on time, the radio is tuned at frequence 87.5 MHz on the US/European FM band, if a station is present then the radio starts reproducing it, otherwise noise is heard. Standard mode (STD) is activated. All entries of the memory array are initialized at 87.5MHz. The backward and forward buttons can be used to select other stations in the band. The search for the next station wraps around the band limits.&lt;br /&gt;
&lt;br /&gt;
Using the mode button, the working mode can be changed. The radio has five operating modes:
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;color:blue&quot;&gt;standard (STD)&lt;/span&gt;: we just described this.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color:blue&quot;&gt;recording (REC)&lt;/span&gt;: in this mode the user can save the current frequency to memory. The user is prompted to choose a slot in the memory in which to store the frequency of the current station. Once the slot number is chosen, press the action button to confirm selection. Use the forward/backward buttons to navigate in the memory array.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color:blue&quot;&gt;memory (MEM)&lt;/span&gt;: reproduces the station memorized at current position in the memory array. Use the forward/ backward buttons to navigate in the memory array.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color:blue&quot;&gt;preselect (PRE)&lt;/span&gt;: this mode automatically preselects the stations with better reception level (SEARCH_LEV_MEDIUM) and memorize them into the memory array. The scan is started from the current frequency toward the superior band limit and restarts from the inferior band limit if the memory has not been completely filled. The filling of the memory follows a greedy policy. The scan is stopped if after two successive trials no station is found.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color:blue&quot;&gt;standby (SBY)&lt;/span&gt;: sets the radio in standby. Press action button to return in STD mode.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;h4&gt;Configuration and fine tuning&lt;/h4&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Configuring the front-end.&lt;/span&gt;
The radio class has been kept as simple as possible. In this way its configuration is very simple. All you need to edit it is the file FM_Radio_Config.h and update information about the pins used by the LCD module. You need also to specify the size of the memory array (constant MEMOMAX) that will be used by the radio to store the frequency of your preferred radio stations.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Configuring the FM module.&lt;/span&gt;
The radio is configured to work with EU/US band limits. If you want to change japanese band limits, then you have to replace EUROPEAN_FM_BAND by JAPANESE_FM_BAND in function TEA576X::begin(). Please check also the working parameters of your FM module (crystal frequency, etc) and configure them accordingly. Remark also that high side injection is selected by default.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Delays.&lt;/span&gt;
In the reading and write operations (immediately after them) it is often used a delay to allow the operation to finish. The delays are sometimes overestimated to be sure to work with most modules. Maybe the user can change them to adapt more closely to his module and increase the overall performances.&lt;br /&gt;
&lt;br /&gt;
Also in the front-end (FM_Radio.cpp) a number of delays are set. Also those can be change to improve performance or user experience.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;h4&gt; Test sketch&lt;/h4&gt;
The simplicity of the design allows to run our radio with a very simple sketch.
&lt;br /&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;FM_Radio.h&amp;quot;&lt;/span&gt;
FM_Radio radio;
&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {
  radio.begin(LCD_BTN, MEMOMAX);
}
&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {
  radio.loop();
}
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;Documentation&lt;/h4&gt;
You may download the full documentation about all classes in this article series in the following formats:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_NmhkaEVxRzNnSm8/view?usp=sharing&quot;&gt;FM-Radio-html.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_Y2E0NTBxY2JWRDQ/view?usp=sharing&quot;&gt;FM-Radio.pdf&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
See also&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 1/4)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/TEA5667-TEA5768-TEA576X-soft.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 2/4)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/01/TEA5767-TEA5768-FM-Module.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 3/4)&lt;/a&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/02/fm-radio-frontend.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzAPpnZOf-WkdmIVszSaeFPieK8tymAyOOjagg99dtcpC5BO6kJw7bl3Q0O5vwRYg9drkoGr7G_KJVFXE8zSI50-WJppfNyMqUsomDrWT40gH_D4aj0C75NA1wuJDr4cuyMNukmpCcm1I/s72-c/LCD-Disp-Info-small.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-593548231207527740</guid><pubDate>Fri, 30 Jan 2015 18:26:00 +0000</pubDate><atom:updated>2015-01-31T10:23:41.984+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">buzzer music</category><category domain="http://www.blogger.com/atom/ns#">HD44780</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">MR007-005.1</category><category domain="http://www.blogger.com/atom/ns#">Software</category><title>A spinning top for your LCD</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx1FEHxrWgLU_vSsjpbDU2LJlE4CNUrOckB-KN6OSuMsHZXYknHqmDIxrLHkCpUclWWPBCMKMBumjQEZZzEeGT2gukXlQ8XCS6eE53Jrc3iXM3sGYQhO2S35NzLQ1w8ghX4fAZtWqjQkg/s1600/SpinningTop.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx1FEHxrWgLU_vSsjpbDU2LJlE4CNUrOckB-KN6OSuMsHZXYknHqmDIxrLHkCpUclWWPBCMKMBumjQEZZzEeGT2gukXlQ8XCS6eE53Jrc3iXM3sGYQhO2S35NzLQ1w8ghX4fAZtWqjQkg/s1600/SpinningTop.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sometimes we need to wait for the end of a task or for an event to occur and at the same time to keep the user informed that the system is not hung. This is the right occasion for a spinning top!&lt;br /&gt;&lt;br /&gt;
In this post we propose a very simple one. Indeed, it is a good occasion to see how to use
the character generator of the LCD and insert new character. The module that we are going
to use is based on the famous Hitachi HD44780 chip. This chip has the possibility to increase
its char set with 4 additional user defined chars. This easily done using the command
&lt;code&gt;createChar&lt;/code&gt; which take in input the id code for the new char (an integer between
0 and 3) and an array of 8 bytes which are interpreted as a bitmap (here we use the 5x8
charset).
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
What you need&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;1x Arduino Uno&lt;/li&gt;
&lt;li&gt;1x LCD module&lt;/li&gt;
&lt;/ul&gt;
Just that! For more on the LCD module you can also have a look &lt;a href=&quot;http://macduino.blogspot.com/2013/11/basic-lcd-module.html&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Configuration&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Modify the definitions of the pins to adapt to your LCD module. In order to change the speed
of the spinner decrease the value of &lt;code&gt;FRAMETIME&lt;/code&gt;. This variable control the frame
rate. Indeed, frame rate is approx 1/FRAMETIME.
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
The sketch&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid #e0efef; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * Spinning top&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; * \date 30 january 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information. All this text must be &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;// modify the definitions below according to your LCD module&lt;/span&gt;
 
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_RS_PIN 7&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_ENABLE_PIN 6&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_DATA4_PIN 5&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_DATA5_PIN 4&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_DATA6_PIN 3&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define LCD_DATA7_PIN 2&lt;/span&gt;

LiquidCrystal &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;lcd&lt;/span&gt;(LCD_RS_PIN, LCD_ENABLE_PIN, LCD_DATA4_PIN,
                  LCD_DATA5_PIN, LCD_DATA6_PIN, LCD_DATA7_PIN);


&lt;span style=&quot;color: #888888;&quot;&gt;// modify the value below to change the frame rate&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// framerate per second is approx 1/FRAMETIME &lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define FRAMETIME 120&lt;/span&gt;


&lt;span style=&quot;color: #888888;&quot;&gt;// the backslash character is not in the standard char set&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;// of the LCD so let&#39;s redefine it&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; backslash[&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;8&lt;/span&gt;] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; {
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00000,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b10000,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b01000,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00100,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00010,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00001,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00000,
    &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b00000
};

&lt;span style=&quot;color: #888888;&quot;&gt;// we use special character 0 here&lt;/span&gt;
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;char&lt;/span&gt; spinningTop[] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; {&lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;/&#39;&lt;/span&gt;, &lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;-&#39;&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0044dd;&quot;&gt;&#39;|&#39;&lt;/span&gt;};
&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; k;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888;&quot;&gt;// put your setup code here, to run once:&lt;/span&gt;
  k &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #888888;&quot;&gt;// init spinner&lt;/span&gt;
  
  &lt;span style=&quot;color: #888888;&quot;&gt;// init screen&lt;/span&gt;
  lcd.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;16&lt;/span&gt;, &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;);
  lcd.createChar(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;, backslash);
  lcd.clear();
  lcd.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Look at me... &quot;&lt;/span&gt;);
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888;&quot;&gt;// update spinner and...&lt;/span&gt;
  lcd.setCursor(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;14&lt;/span&gt;,&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
  lcd.write(spinningTop[k&lt;span style=&quot;color: #333333;&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4&lt;/span&gt;]);
  k &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; (k&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #333333;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;b11;
  &lt;span style=&quot;color: #888888;&quot;&gt;// ...waste some time to let user see it spinning&lt;/span&gt;
  delay(FRAMETIME);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;Suggestions&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Remark that our implementation of the spinner uses busy waiting. In order to avoid it one
can use interrupts. However, if you decide to use interrupts, recall that they can interfere
with other modules or sensors and that Arduino Uno only has two of them!
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;Enjoy!&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/01/a-spinning-top-for-your-lcd.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx1FEHxrWgLU_vSsjpbDU2LJlE4CNUrOckB-KN6OSuMsHZXYknHqmDIxrLHkCpUclWWPBCMKMBumjQEZZzEeGT2gukXlQ8XCS6eE53Jrc3iXM3sGYQhO2S35NzLQ1w8ghX4fAZtWqjQkg/s72-c/SpinningTop.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-382008642220782297</guid><pubDate>Sun, 11 Jan 2015 22:14:00 +0000</pubDate><atom:updated>2015-02-01T22:25:30.890+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo module</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">MR007-005.1</category><category domain="http://www.blogger.com/atom/ns#">TEA5767</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HL</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HN</category><category domain="http://www.blogger.com/atom/ns#">TEA5768</category><category domain="http://www.blogger.com/atom/ns#">TEA5768HL</category><title>FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757)(Part 3/4)</title><description>&lt;div style=&quot;margin-left: auto; margin-right: auto; text-align: justify; width: 75%;&quot;&gt;
&lt;h4&gt;
Abstract&lt;/h4&gt;
In this third part we provide a class for the FM module and a simple test program.
The next post will provide a basic FM Radio front-end as an application
of the FM module.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The FM module&lt;/b&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
As we have already said in past posts, this is a decoration module for a module based
on the TEA5767HN chip. In particular, it fixes some important parameters such as
the clock and the bus.
Here are the main characteristics of the module:
&lt;style&gt;
.char-row {
   display:table-row;border-bottom: 1px solid #2288BB;
}
.char-head {
   font-family: &#39;Oswald&#39;, sans-serif; font-size: 9pt; font-weight: bold; text-transform: uppercase;display:table-cell;border-bottom: 1px solid #2288BB;
}
.char-cell {
   font-size: 8pt; display:table-cell;border-bottom: 1px dotted #333; padding-top: 3px;
}
.boldize {
   font-weight: bold; width:55% 
}
.reduced {
   text-align:right; width:45%
}
&lt;/style&gt;
&lt;div style=&quot;margin-left:auto;margin-right:auto;display:table;padding-top:10px;width:40%&quot;&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-head&quot;&gt;Main characteristics&lt;/div&gt;&lt;div class=&quot;char-head&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;Supply voltage:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;3V-6V&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;Working current:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;25mA&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;Audio output:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;2x10mW&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;Clock:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;32768Hz&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;Bus:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;I2C&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;char-row&quot;&gt;
  &lt;div class=&quot;char-cell boldize&quot;&gt;I2C address:&lt;/div&gt;&lt;div class=&quot;char-cell reduced&quot;&gt;0x60&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br/&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
We have therefore conceived a wrap class which hides all the details about TEA5767HN, sets
up the above constraints and provides few basic methods for the final user. Please look into
the code below for the methods and for documentation. The pinout of the module is given
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
&lt;!---             ---&gt;
&lt;!--- FM_Module.h ---&gt;
&lt;!---             ---&gt;
&lt;br/&gt;&lt;br/&gt;
We start with the file &lt;code&gt;FM_Module.h&lt;/code&gt;:&lt;br/&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \file FM_Module.h&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \brief A class for the FM module based on the TEA5767HN chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#ifndef ____FM_Module__h&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#define ____FM_Module__h&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5767HN.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \class FM_Module&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \brief A class for the FM module based on the TEA5767HN chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * \details This is a simple class for a FM module based on the TEA5767HN chip. The class implements&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; * faithfully the module functioning. Moreover, it provides some basic commands for FM radio playing.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;*/&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #BB0066; font-weight: bold&quot;&gt;FM_Module&lt;/span&gt; {
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \var TEA5767HN FM&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief This is the internal FM receiver which pratically does all the job.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see TEA5767HN&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    TEA5767HN FM;
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \var bool standby&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Flag for signalling if the standby is enabled. This is a quick trick to avoid unuseful call to the TEA5767HN module.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; _standby;
&lt;span style=&quot;color: #997700; font-weight: bold&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn void begin()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Initialize the FM module. This command has always to be issued before using the module.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;begin&lt;/span&gt;();
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn void setFrequency(float f)&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Set the frequency of the FM receiver.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * @param float f The desired frequency in MHz.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see getFrequency()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setFrequency&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;float&lt;/span&gt; f) { FM.setFrequency(f); };
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn float getFrequency()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Returns the frequency on which the receiver is tuned&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \return Returns the frequency in MHz on which the tuner is tuned.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;getFrequency&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;return&lt;/span&gt; FM.getFrequency(); };
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn bool searchForward()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Search for a station in the direction of the superior band limit. &lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \return \c true if the search is successful, \c false otherwise.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see searchBackward()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * Search for a station in the direction of the superior band limit. If the superior band limit is reached, then the search restarts from the inferior band limit.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * The search is abandoned after one complete loop.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;searchForward&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;return&lt;/span&gt; FM.search(SEARCH_DIR_FORWARD, SEARCH_LEV_MEDIUM); };
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn bool searchBackward()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Search for a station in the direction of the inferior band limit.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \return \c true if the search is successful, \c false otherwise.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see searchForward()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * Search for a station in the direction of the inferior band limit. If the inferior band limit is reached, then the search restarts from the superior band limit.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * The search is abandoned after one complete loop.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;searchBackward&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;return&lt;/span&gt; FM.search(SEARCH_DIR_BACKWARD, SEARCH_LEV_MEDIUM); };
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn void refresh()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Refreshes the internal state of the FM module.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * Refreshes the internal state of the FM module. This is particularly useful before issuing commands like isStereo() or getLevel()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;refresh&lt;/span&gt;() { FM.read(); }
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn void standby()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief Put the FM module in standby state&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;standby&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #333333&quot;&gt;!&lt;/span&gt;_standby){_standby &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020&quot;&gt;true&lt;/span&gt;; FM.standby(STANDBY_ON); FM.write();}};
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn void play()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief The tuner is set into play state.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;play&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(_standby) {FM.standby(STANDBY_OFF); FM.write(); _standby&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #007020&quot;&gt;false&lt;/span&gt;;}};
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn bool isStereo()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief This function queries for the current quality of the reproduction: stereo or mono.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \return \c true if the reproduction is stereo, \c false if it is mono.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see refresh()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \warning It is better to issue a \c refresh() command before calling this function in order to have fresh informations from the receiver.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;isStereo&lt;/span&gt;(){ &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;return&lt;/span&gt; FM.isStereo(); };
    &lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \fn uint8_t getLevel()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \brief This function returns the output level of the receiver.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \return An integer between 0 and 15 indicating the output level of the receiver.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \see refresh()&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     * \warning It is better to issue a \c refresh() command before calling this function in order to have fresh informations from the receiver.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;getLevel&lt;/span&gt;() { &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;return&lt;/span&gt; FM.getLevel(); };
};


&lt;span style=&quot;color: #557799&quot;&gt;#endif &lt;/span&gt;&lt;span style=&quot;color: #888888&quot;&gt;/* defined(____FM_Module__h) */&lt;/span&gt;&lt;span style=&quot;color: #557799&quot;&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;&lt;br/&gt;
Here is the file FM_Module.cpp:
&lt;br/&gt;
&lt;!---               ---&gt;
&lt;!--- FM_Module.cpp ---&gt;
&lt;!---               ---&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \file FM_Module.cpp&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \brief Implementation of a class for the FM module based on the TEA5767HN chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 18 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information. All this text must be&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;FM_Module.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; FM_Module&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;begin() {
    Wire.begin();               &lt;span style=&quot;color: #888888&quot;&gt;// Init I2C bus&lt;/span&gt;
    FM.begin(TEA576X_XTAL_32768Hz, TEA5767HN_I2CBUS); &lt;span style=&quot;color: #888888&quot;&gt;// Init TEA receiver&lt;/span&gt;
    _standby &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #007020&quot;&gt;false&lt;/span&gt;;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;
And finally a very basic test sketch :-)
&lt;br/&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;FM_Module.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5767HL.h&amp;quot;&lt;/span&gt;

FM_Module mod;
TEA5767HL tea;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {

  mod.begin();

  mod.searchForward();
  
  mod.play();
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888&quot;&gt;// listening to Radio don&amp;#39;t care here ;-)&lt;/span&gt;

}
&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;h4&gt;What&#39;s next&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
As promised in the last post of this series we will see a basic FM Radio front-end with
LCD support. 
&lt;/div&gt;
&lt;br/&gt;
&lt;h4&gt;See also&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 1/4)&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/TEA5667-TEA5768-TEA576X-soft.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 2/4)&lt;/a&gt;&lt;br &gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/02/fm-radio-frontend.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 4/4)&lt;/a&gt;
&lt;/div&gt;</description><link>https://macduino.blogspot.com/2015/01/TEA5767-TEA5768-FM-Module.html</link><author>noreply@blogger.com (Maczinga)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-307111410307142588</guid><pubDate>Wed, 31 Dec 2014 14:59:00 +0000</pubDate><atom:updated>2015-02-01T22:26:30.200+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo module</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">MR007-005.1</category><category domain="http://www.blogger.com/atom/ns#">TEA5767</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HL</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HN</category><category domain="http://www.blogger.com/atom/ns#">TEA5768</category><category domain="http://www.blogger.com/atom/ns#">TEA5768HL</category><title>FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757)(Part 2/4)</title><description>&lt;style&gt;

        .mybutton {
            display: inline-block;
            height: 24px;
            line-height: 24px;
            padding-right: 26px;
            padding-left: 40px;
            position: relative;
            background-color:rgb(41,127,184);
            color:rgb(255,255,255);
            text-decoration: none;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 15px;
            
            
            border-radius: 5px;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            text-shadow:0px 1px 0px rgba(0,0,0,0.5);
            -ms-filter:&quot;progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=1,Color=#ff123852,Positive=true)&quot;;zoom:1;
            filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=1,Color=#ff123852,Positive=true);
            
            -moz-box-shadow:0px 2px 2px rgba(0,0,0,0.2);
            -webkit-box-shadow:0px 2px 2px rgba(0,0,0,0.2);
            box-shadow:0px 2px 2px rgba(0,0,0,0.2);
            -ms-filter:&quot;progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=2,Color=#33000000,Positive=true)&quot;;
            filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=2,Color=#33000000,Positive=true);
        }
    
    .mybutton span {
       position: absolute;
        left: 0;
        width: 16px;
        background-color:rgba(0,0,0,0.65);
        
        -webkit-border-top-left-radius: 5px;
        -webkit-border-bottom-left-radius: 5px;
        -moz-border-radius-topleft: 5px;
        -moz-border-radius-bottomleft: 5px;
        border-top-left-radius: 5px;
        border-bottom-left-radius: 5px;
        border-right: 1px solid  rgba(0,0,0,0.15);
    }
    
    .mybutton:hover span, .mybutton.active span {
        background-color:rgb(0,102,26);
        border-right: 1px solid  rgba(0,0,0,0.3);
    }
    
    .mybutton:active {
        margin-top: 2px;
        margin-bottom: 13px;
        
        -moz-box-shadow:0px 1px 0px rgba(255,255,255,0.8);
        -webkit-box-shadow:0px 1px 0px rgba(255,255,255,0.8);
        box-shadow:0px 1px 0px rgba(255,255,255,0.8);
        -ms-filter:&quot;progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=1,Color=#ccffffff,Positive=true)&quot;;
        filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=0,OffY=1,Color=#ccffffff,Positive=true);
    }
    
    .mybutton.orange {
        background: #FF7F00;
    }
    
    .mybutton.purple {
        background: #8e44ad;
    }
    
    .mybutton.turquoise {
        background: #1abc9c;
    }
    
    .mybutton.red {
        background: #e74c3c;
    }
        /* fonctionnel */
    .mytree input {
        display: none;
    }
    .mytree input ~ ul {
        display: none;
    }
    .mytree input:checked ~ ul {
        display: block;
    }
    
    .mytree input + span &gt; .fa-arrow-down {
        display: none;
    }
    .mytree input:checked + span &gt; .fa-arrow-right {
        display: none;
    }
    .mytree input:checked + span &gt; .fa-arrow-down {
        display: inline;
    }
    
    .mytree input ~ .hidden-label {
        display:none;
    }
    .mytree input:checked ~ .hidden-label {
        display:inline-block;
    }

    .mytree input ~ .normal-label {
        display:inline-block;
    }
    .mytree input:checked ~ .normal-label {
        display:none;
    }

    .mytree input[type=checkbox] {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .mydiv input[type=checkbox] {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
.collapsed {
position:relative;top:-17px;clear:both;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;
}
.expanded {
position:relative;top:-17px;clear:both;display:none;background: #ffffff; overflow:auto;width:auto;border:solid #e0efef;border-width:.1em .1em .1em .1em;padding:.2em .6em;
}
&lt;/style&gt;
&lt;script&gt;
    function mytoggle(showHideDiv1, showHideDiv2) {
        var ele1 = document.getElementById(showHideDiv1);
        var ele2 = document.getElementById(showHideDiv2);
        if(ele1.style.display == &quot;none&quot;) {
            ele1.style.display = &quot;block&quot;;
            ele2.style.display = &quot;none&quot;;
        }
        else {
            ele1.style.display = &quot;none&quot;;
            ele2.style.display = &quot;block&quot;;
        }
    }
&lt;/script&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-left: auto; margin-right: auto; text-align: justify; width: 75%;&quot;&gt;
&lt;h4&gt;
Abstract&lt;/h4&gt;
In this second part we provide C++ classes to deal with TEA576X family of chips. We also
provide a basic sketch for using the TEA5767HN module that one may buy for few bucks. The next post will be concerned with
the FM module and the last one will provide an example of (basic) FM Radio as an application
of the FM module.
&lt;/div&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;h4&gt;Updated&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
After further tests some bugs were found. Here is the list:
&lt;ul&gt;
&lt;li&gt;Read procedures in TEA5767HN.cpp and TEA5768HL.cpp&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#define&lt;/code&gt; constants in TEA576X.h&lt;/li&gt;
&lt;li&gt;Search procedure in TEA576X.cpp&lt;/li&gt;
&lt;/ul&gt;
Please download all those files again!
&lt;/div&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TEA576X&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Recall that the chips of the family TEA576X differ only for the communication protocol
(SPI or I2C). We have therefore conceived an abstract class, &lt;code&gt;TEA576X&lt;/code&gt;, which
implements all the methods except the &lt;code&gt;write&lt;/code&gt; and &lt;code&gt;read&lt;/code&gt; functions that are delegated to the
derived classes. Both the header and the implementation files are pretty long, you can
download them below:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_M2VQWllwTUxXZUE&amp;amp;authuser=0&quot;&gt;TEA576X.h&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_NW9ma3VNeFNUdjg&amp;amp;authuser=0&quot;&gt;TEA576X.cpp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The headers&lt;/b&gt;
&lt;br /&gt;
Choose the header you need for your sketches. Save these files as &lt;code&gt;ClassName.h&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onClick=&quot;mytoggle(&#39;TEA5767HL-h-collapsed&#39;,&#39;TEA5767HL-h-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5767HL-h&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onClick=&quot;mytoggle(&#39;TEA5767HL-h-collapsed&#39;,&#39;TEA5767HL-h-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5767HL-h&quot; onClick=&quot;mytoggle(&#39;TEA5767HL-h-collapsed&#39;,&#39;TEA5767HL-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5767HL-h&quot; onClick=&quot;mytoggle(&#39;TEA5767HL-h-collapsed&#39;,&#39;TEA5767HL-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Class TEA5767HL&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5767HL-h-collapsed&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5767HL&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA576X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;private:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; _SSPin; &lt;span style=&quot;color: #888888;&quot;&gt;// Slave Select pin&lt;/span&gt;
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; SSpin);
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;write&lt;/span&gt;();
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;read&lt;/span&gt;();
};
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5767HL-h-expanded&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \file TEA5767HL.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \brief A class for dealing with TEA5767HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#ifndef ____TEA5767HL__&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define ____TEA5767HL__&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#if ARDUINO &amp;gt;= 100&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;Arduino.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#else&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;WProgram.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#endif&lt;/span&gt;


&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA576X.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define M_FM_TEA5767HL 0xC8189CB3&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \class TEA5767HL TEA5767HL.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \brief A class for TEA5767HL component.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; This class implements the methods to interact with the TEA5767HL component&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; which is a FM receiver. For more on this component refer to&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \see TEA576X&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5767HL&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA576X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;private:&lt;/span&gt;
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     * \var _SSPin&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     * \brief Slave Select pin for the SPI protocol.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; _SSPin; &lt;span style=&quot;color: #888888;&quot;&gt;// Slave Select pin&lt;/span&gt;
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        \fn void begin(float xtal, uint8_t SSpin)&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        \brief Init TEA5767HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        @param SSpin Slave Select pin.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; SSpin);
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \fn void write()&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \brief Send the current write sequence to the TEA5767HL.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \warning All the operations or changes to the module settings have no effect&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     untill a write() operation is issued.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;write&lt;/span&gt;();
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \fn void read()&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \brief Read-in the current read sequence of the TEA5767HL.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;read&lt;/span&gt;();
};


&lt;span style=&quot;color: #557799;&quot;&gt;#endif &lt;/span&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/* defined(____TEA5767HL__) */&lt;/span&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- --&gt;
&lt;!-- File TEA5768HL-H --&gt;
&lt;!-- --&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot; onClick=&quot;mytoggle(&#39;TEA5768HL-h-collapsed&#39;,&#39;TEA5768HL-h-expanded&#39;)&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onClick=&quot;mytoggle(&#39;TEA5768HL-h-collapsed&#39;,&#39;TEA5768HL-h-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5768HL-h&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onClick=&quot;mytoggle(&#39;TEA5768HL-h-collapsed&#39;,&#39;TEA5768HL-h-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5768HL-h&quot; onClick=&quot;mytoggle(&#39;TEA5768HL-h-collapsed&#39;,&#39;TEA5768HL-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5768HL-h&quot; onClick=&quot;mytoggle(&#39;TEA5768HL-h-collapsed&#39;,&#39;TEA5768HL-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Class TEA5768HL&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5768HL-h-collapsed&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5768HL&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA576X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;write&lt;/span&gt;();
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;read&lt;/span&gt;();
};
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5768HL-h-expanded&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \file TEA5768HL.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \brief A class for dealing with TEA5768HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \author Enrico Formenti,&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information. All this text must be &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#ifndef ____TEA5768HL__h&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define ____TEA5768HL__h&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#if ARDUINO &amp;gt;= 100&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;Arduino.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#else&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;WProgram.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#endif&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA576X.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define M_FM_TEA5767HL 0x717D6A52&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \class TEA5768HL TEA5768HL.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \brief A class for TEA5768HL component.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; This class implements the methods to interact with the TEA5768HL component&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; which is a FM receiver. For more on this component refer to&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \see TEA576X&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5768HL&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA576X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \fn void write()&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \brief Send the current write sequence to the TEA5768HL.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \warning All the operations or changes to the module settings have no effect&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     untill a write() operation is issued.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;write&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- --&gt;
&lt;!-- File TEA5767HN-H --&gt;
&lt;!-- --&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-h-collapsed&#39;,&#39;TEA5767HN-h-expanded&#39;)&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-h-collapsed&#39;,&#39;TEA5767HN-h-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5767HN-h&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onclick=&quot;mytoggle(&#39;TEA5767HN-h-collapsed&#39;,&#39;TEA5767HN-h-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5767HN-h&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-h-collapsed&#39;,&#39;TEA5767HN-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5767HN-h&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-h-collapsed&#39;,&#39;TEA5767HN-h-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Class TEA5767HN&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5767HN-h-collapsed&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5767HN&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA5767X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;private:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; _bustype;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; _SSPin; &lt;span style=&quot;color: #888888;&quot;&gt;// Slave Select pin&lt;/span&gt;
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; bus, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; SSpin&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;write&lt;/span&gt;();
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;read&lt;/span&gt;();
};
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;

&lt;br /&gt;
&lt;div id=&quot;TEA5767HN-h-expanded&quot; style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid #e0efef; clear: both; display: none; overflow: auto; padding: .2em .6em; position: relative; top: -17px; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  TEA5767HN.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  A class for dealing with TEA5767HN.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  Written by Enrico Formenti, 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#ifndef ____TEA5767HN__&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define ____TEA5767HN__&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA576X.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &amp;lt;SPI.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &amp;lt;Wire.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define M_FM_TEA5767HL 0x728E2149&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEA5767HN_3WIREBUS true&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEA5767HN_I2CBUS false&lt;/span&gt;

&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \class TEA5767HN TEA5767HN.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \brief A class for TEA5767HN component.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; This class implements the methods to interact with the TEA5767HN component&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; which is a stereo FM receiver. For more on this component refer to&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; \see TEA576X&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;TEA5767HN&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; TEA5767X {
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;private:&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; _bustype;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; _SSPin; &lt;span style=&quot;color: #888888;&quot;&gt;// Slave Select pin&lt;/span&gt;
&lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;public:&lt;/span&gt;
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        \fn void begin(float xtal, uint8_t SSpin)&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        \brief Init TEA5767HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;        @param SSpin Slave Select pin.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;    */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;begin&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;bool&lt;/span&gt; bus, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; SSpin&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;);
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \fn void write()&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \brief Send the current write sequence to the TEA5767HN.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \warning All the operations or changes to the module settings have no effect&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     untill a write() operation is issued.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;write&lt;/span&gt;();
    &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \fn void read()&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     \brief Read-in the current read sequence of the TEA5767HN.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;     */&lt;/span&gt;
    &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;read&lt;/span&gt;();
};
&lt;span style=&quot;color: #557799;&quot;&gt;#endif &lt;/span&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/* defined(____TEA5767HL__) */&lt;/span&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;Warning:&lt;/span&gt; If you have installed Arduino 1.5.8 Beta, then you need to install SPI library manually from GitHub. It can be found &lt;a href=&quot;https://github.com/arduino/Arduino/tree/master/libraries/SPI&quot;&gt;here&lt;/a&gt;. If you have an older version (1.0.6 for example) then there is no problem since it comes with the SPI library
pre-installed.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Implementing the classes&lt;/b&gt;
&lt;br /&gt;
Choose the files you need for your sketches and save the files as &lt;code&gt;ClassName.cpp&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;!--            --&gt;
&lt;!-- 5767HL.cpp --&gt;
&lt;!--            --&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onclick=&quot;mytoggle(&#39;TEA5767HL-cpp-collapsed&#39;,&#39;TEA5767HL-cpp-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5767HL-cpp&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onclick=&quot;mytoggle(&#39;TEA5767HL-cpp-collapsed&#39;,&#39;TEA5767HL-cpp-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5767HL-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5767HL-cpp-collapsed&#39;,&#39;TEA5767HL-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5767HL-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5767HL-cpp-collapsed&#39;,&#39;TEA5767HL-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-left: 120px; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Implementation of the class TEA5767HL&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5767HL-cpp-collapsed&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; TEA5767HL&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; i;
    
    digitalWrite(_SSPin, LOW);   
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;)
        SPI.transfer(wbuf[i]);
    digitalWrite(_SSPin, HIGH);
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; TEA5767HL&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; i;
    
    digitalWrite(_SSPin, LOW);    
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;)
        rbuf[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; SPI.transfer(&lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0x0&lt;/span&gt;);    
    digitalWrite(_SSPin, HIGH);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5767HL-cpp-expanded&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \file TEA5767HL.cpp&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \brief Implementation of a class for dealing with TEA5767HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA5767HL.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; TEA5767HL&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;begin(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; SSpin) {
    TEA576X&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;begin(xtal);
    _SSPin &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; SSpin;
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; TEA5767HL&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; i;
    
    &lt;span style=&quot;color: #888888;&quot;&gt;// take the SS pin low to select the chip:&lt;/span&gt;
    digitalWrite(_SSPin,LOW);
    
    &lt;span style=&quot;color: #888888;&quot;&gt;// send buffer data&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;)
        SPI.transfer(wbuf[i]);

    &lt;span style=&quot;color: #888888;&quot;&gt;// take the SS pin high to de-select the chip:&lt;/span&gt;
    digitalWrite(_SSPin,HIGH);
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; TEA5767HL&lt;span style=&quot;color: #333333;&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint8_t&lt;/span&gt; i;
    
    &lt;span style=&quot;color: #888888;&quot;&gt;// take the SS pin low to select the chip:&lt;/span&gt;
    digitalWrite(_SSPin,LOW);
    
    &lt;span style=&quot;color: #888888;&quot;&gt;// read-in buffer data&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;)
        rbuf[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; SPI.transfer(&lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0x0&lt;/span&gt;);
    
    &lt;span style=&quot;color: #888888;&quot;&gt;// take the SS pin high to de-select the chip:&lt;/span&gt;
    digitalWrite(_SSPin,HIGH);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;!--            --&gt;
&lt;!-- 5768HL.cpp --&gt;
&lt;!--            --&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onclick=&quot;mytoggle(&#39;TEA5768HL-cpp-collapsed&#39;,&#39;TEA5768HL-cpp-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5768HL-cpp&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onclick=&quot;mytoggle(&#39;TEA5768HL-cpp-collapsed&#39;,&#39;TEA5768HL-cpp-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5768HL-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5768HL-cpp-collapsed&#39;,&#39;TEA5768HL-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5768HL-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5768HL-cpp-collapsed&#39;,&#39;TEA5768HL-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-left: 120px; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Implementation of the class TEA5768HL&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5768HL-cpp-collapsed&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5768HL.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5768HL&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i;
    
    Wire.beginTransmission(TEA576X_I2C_ADDRESS);
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
        Wire.write(wbuf[i]);
    Wire.endTransmission();
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5768HL&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
    
    Wire.requestFrom(TEA576X_I2C_ADDRESS, &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;);    
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;while&lt;/span&gt;(Wire.available())
        rbuf[i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; Wire.read();
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5768HL-cpp-expanded&quot;&gt;
&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \file TEA5768HL.cpp&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \brief Implementation of a class for dealing with TEA5768HL chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 22 jan 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \version 1.1&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5768HL.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5768HL&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i;
    
    Wire.beginTransmission(TEA576X_I2C_ADDRESS);
    
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
        Wire.write(wbuf[i]);
    
    Wire.endTransmission();
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5768HL&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
    
    Wire.requestFrom(TEA576X_I2C_ADDRESS, &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;);
    
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;while&lt;/span&gt;(Wire.available())
        rbuf[i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; Wire.read();
}
&lt;/pre&gt;&lt;/div&gt;
&lt;!--            --&gt;
&lt;!-- 5767HN.cpp --&gt;
&lt;!--            --&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-cpp-collapsed&#39;,&#39;TEA5767HN-cpp-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5767HN-cpp&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onclick=&quot;mytoggle(&#39;TEA5767HN-cpp-collapsed&#39;,&#39;TEA5767HN-cpp-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5767HN-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-cpp-collapsed&#39;,&#39;TEA5767HN-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5767HN-cpp&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-cpp-collapsed&#39;,&#39;TEA5767HN-cpp-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-left: 120px; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
Implementation of the class TEA5767HN&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5767HN-cpp-collapsed&quot;&gt;
&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5767HN.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;begin(&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; bus, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; SSpin) {
    _bustype &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; bus;
    _SSPin &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; SSpin;
    TEA576X&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;begin(xtal);
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i;
    
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(_bustype) {
        digitalWrite(_SSPin,LOW);
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            SPI.transfer(wbuf[i]);
        digitalWrite(_SSPin,HIGH);
    }
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;else&lt;/span&gt; {
        Wire.beginTransmission(TEA576X_I2C_ADDRESS);        
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            Wire.write(wbuf[i]);
        Wire.endTransmission();
    }
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;

    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(_bustype) {
        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin low to select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,LOW);
    
        &lt;span style=&quot;color: #888888&quot;&gt;// read-in buffer data&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            rbuf[i] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; SPI.transfer(&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x0&lt;/span&gt;);
    
        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin high to de-select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,HIGH);
    }
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;else&lt;/span&gt; {
        
        Wire.requestFrom(TEA576X_I2C_ADDRESS, &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;);
        
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;while&lt;/span&gt;(Wire.available())
            rbuf[i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; Wire.read();
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5767HN-cpp-expanded&quot;&gt;
&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \file TEA5767HN.cpp&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \brief Implementation of a class for dealing with TEA5767HN chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 23 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \date 22 jan 2015&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \version 1.1&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;TEA5767HN.h&amp;quot;&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;begin(&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;float&lt;/span&gt; xtal, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;bool&lt;/span&gt; bus, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; SSpin) {
    _bustype &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; bus;
    _SSPin &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; SSpin;
    TEA576X&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;begin(xtal);
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;write() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i;
    
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(_bustype) {
        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin low to select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,LOW);
    
        &lt;span style=&quot;color: #888888&quot;&gt;// send buffer data&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            SPI.transfer(wbuf[i]);

        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin high to de-select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,HIGH);
    }
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;else&lt;/span&gt; {
        Wire.beginTransmission(TEA576X_I2C_ADDRESS);
        
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            Wire.write(wbuf[i]);
        
        Wire.endTransmission();

    }
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; TEA5767HN&lt;span style=&quot;color: #333333&quot;&gt;::&lt;/span&gt;read() {
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint8_t&lt;/span&gt; i &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;

    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(_bustype) {
        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin low to select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,LOW);
    
        &lt;span style=&quot;color: #888888&quot;&gt;// read-in buffer data&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;for&lt;/span&gt;(; i&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;; i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;)
            rbuf[i] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; SPI.transfer(&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x0&lt;/span&gt;);
    
        &lt;span style=&quot;color: #888888&quot;&gt;// take the SS pin high to de-select the chip:&lt;/span&gt;
        digitalWrite(_SSPin,HIGH);
    }
    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;else&lt;/span&gt; {
        
        Wire.requestFrom(TEA576X_I2C_ADDRESS, &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;5&lt;/span&gt;);
        
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;while&lt;/span&gt;(Wire.available())
            rbuf[i&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;] &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; Wire.read();
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The sketch&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In order to test the the above classes here is a simple sketch. To run the sketch you need
the files TEA5767.* (see above), TEA5767HN.* (see above) and, of course, a TEA5767 FM module
(see Figure 2 in &lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;this&lt;/a&gt; post). The sketch initialises the TEA5767HN and then search for a station. If one is found
then the module is tuned at this frequency. Pay attention that by default the tuner uses
the US/European FM band (87.5-108MHz), if you need the Japanese FM band (76-91MHz), then
you should add the following instruction after &lt;code&gt;tea.begin(...);&lt;/code&gt;:
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;code&gt;tea.setBandLimits(JAPANESE_FM_BAND);&lt;/code&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e0efef; height: 30px;&quot;&gt;
&lt;div class=&quot;mytree&quot; style=&quot;display: block; float: left; padding-bottom: 4px; padding-top: 4px;&quot;&gt;
&lt;div class=&quot;mybutton turquoise&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-test-collapsed&#39;,&#39;TEA5767HN-test-expanded&#39;)&quot;&gt;
&lt;input id=&quot;source-TEA5767HN-test&quot; type=&quot;checkbox&quot; /&gt;
                &lt;span onclick=&quot;mytoggle(&#39;TEA5767HN-test-collapsed&#39;,&#39;TEA5767HN-test-expanded&#39;)&quot; style=&quot;height: 24px; padding-left: 10px; padding-right: 4px; padding-top: 0px;&quot;&gt;
                    &lt;i class=&quot;fa fa-arrow-right&quot;&gt;&lt;/i&gt;
                    &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;
                &lt;/span&gt;
                &lt;label class=&quot;hidden-label&quot; for=&quot;source-TEA5767HN-test&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-test-collapsed&#39;,&#39;TEA5767HN-test-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Collapse&lt;/label&gt;
                &lt;label class=&quot;normal-label&quot; for=&quot;source-TEA5767HN-test&quot; onclick=&quot;mytoggle(&#39;TEA5767HN-test-collapsed&#39;,&#39;TEA5767HN-test-expanded&#39;)&quot; style=&quot;width: 74px;&quot;&gt;Expand&lt;/label&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #00661a; font-weight: bold; margin-right: auto; marginleft: auto; padding-left: 120px; padding-top: 8px; text-align: center; text-shadow: 0px 1px 0px rgba(0,0,0,0.5); width: 400px;&quot;&gt;
The sketch TEA5767HN-test.ino&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;collapsed&quot; id=&quot;TEA5767HN-test-collapsed&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA5767HN.h&quot;&lt;/span&gt;

TEA5767HN tea;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  Serial.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;9600&lt;/span&gt;);
  
  tea.begin(TEA576X_XTAL_32768Hz, TEA5767HN_I2CBUS);
  
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #333333;&quot;&gt;!&lt;/span&gt;tea.search(SEARCH_DIR_FORWARD, SEARCH_LEV_MEDIUM)) {
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Couldn&#39;t find any station!&quot;&lt;/span&gt;);
  }
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; {
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Playing station at &quot;&lt;/span&gt;);
    Serial.print(tea.getFrequency()&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1000000.0&lt;/span&gt;);
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;MHz&quot;&lt;/span&gt;);
  }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;
&lt;div class=&quot;expanded&quot; id=&quot;TEA5767HN-test-expanded&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \file TEA5767HN-test.ino&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \brief A quick example for testing the TEA5767HN chip.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \author Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \date 27 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \version 1.0&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  \copyright BSD license, check the License page on the blog for more information. All this text must be &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;
 
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;TEA5767HN.h&quot;&lt;/span&gt;

TEA5767HN tea;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  Serial.begin(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;9600&lt;/span&gt;);
  
  tea.begin(TEA576X_XTAL_32768Hz, TEA5767HN_I2CBUS);
  
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #333333;&quot;&gt;!&lt;/span&gt;tea.search(SEARCH_DIR_FORWARD, SEARCH_LEV_MEDIUM)) {
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Couldn&#39;t find any station!&quot;&lt;/span&gt;);
  }
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; {
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Playing station at &quot;&lt;/span&gt;);
    Serial.print(tea.getFrequency()&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1000000.0&lt;/span&gt;);
    Serial.print(&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;MHz&quot;&lt;/span&gt;);
  }
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888;&quot;&gt;// nothing to do at present...&lt;/span&gt;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
To run this sketch you need:
&lt;ul&gt;
&lt;li&gt;1x Arduino Uno (or one of his brothers)&lt;/li&gt;
&lt;li&gt;1x TEA5767HN chip&lt;/li&gt;
&lt;li&gt;1x louspeaker 4&amp;Omega; 1/4 Watt (or similar)&lt;/li&gt;
&lt;li&gt;7x Dupont connection cables&lt;/li&gt;
&lt;li&gt;1x long enough cable for the antenna (more details &lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
Figure 1. shows how to connect the material. Remark that the output level of the module
is very weak. This is the reason for which one finds many modules that adds to TEA5767HN
an amplification stage, like the one that we will see in the next post.
&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3yDQ_oN5ArbMN9LGCsW64W10sbNXJqYyHqTWv9pdTaZ8w8nEo7rjMBoffg2M1MTENXtZkkwMWvFR4aClZZEAfYNW9Zx8SKlemzPbfbvPQXtv-BgCR85JabRhU_A1l3c6b_aybhlovsJw/s1600/TEA5767HN-basic-connections_bb.png&quot; height=&quot;263&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. Basic connections for the TEA5767HN module.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;What&#39;s next&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
As promised in the abstract we will provide a class for
dealing with the FM module and finally an application example building a simple FM radio
player front-end.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;See also&lt;/b&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html&quot;&gt;FM Radio receiver (TEA5767HL-TEA5767HN-TEA5768HL) - Part 1&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/01/TEA5767-TEA5768-FM-Module.html&quot;&gt;FM Radio receiver (TEA5767HL-TEA5767HN-TEA5768HL) - Part 3&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/02/fm-radio-frontend.html&quot;&gt;FM Radio receiver (TEA5767HL-TEA5767HN-TEA5768HL) - Part 4&lt;/a&gt;</description><link>https://macduino.blogspot.com/2014/12/TEA5667-TEA5768-TEA576X-soft.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3yDQ_oN5ArbMN9LGCsW64W10sbNXJqYyHqTWv9pdTaZ8w8nEo7rjMBoffg2M1MTENXtZkkwMWvFR4aClZZEAfYNW9Zx8SKlemzPbfbvPQXtv-BgCR85JabRhU_A1l3c6b_aybhlovsJw/s72-c/TEA5767HN-basic-connections_bb.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-4036264500879704382</guid><pubDate>Wed, 24 Dec 2014 16:17:00 +0000</pubDate><atom:updated>2017-01-21T18:18:43.044+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">arduino music</category><category domain="http://www.blogger.com/atom/ns#">arduino sound</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">music</category><category domain="http://www.blogger.com/atom/ns#">tone music</category><title>Tone music: changing the Tempo of your melodies</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzPO3qkW3um3ZHb_6YtqLIk1kRq4xG8kJCdKTNT3lFzuBGHbblJv2bjUgp3OcapxNtVQF41ZCSj-2oInMn3eey6L0hWpksDYQYFCHhBUPfaTohqCVAp5zqucKMXos7OrkY2pJ_D_gGaBg/s1600/2000px-MozartExcerptK331.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzPO3qkW3um3ZHb_6YtqLIk1kRq4xG8kJCdKTNT3lFzuBGHbblJv2bjUgp3OcapxNtVQF41ZCSj-2oInMn3eey6L0hWpksDYQYFCHhBUPfaTohqCVAp5zqucKMXos7OrkY2pJ_D_gGaBg/s400/2000px-MozartExcerptK331.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 80%;&quot;&gt;
&lt;b&gt;Abstract&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In our past programs for playing tone music on Arduino (see the basic program
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;here&lt;/a&gt; and its advanced version &lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;here&lt;/a&gt;) are based on a fixed Tempo which is about 90 crotchets
per minute. In this article we give a simple routine which allows to change the Tempo.
We also provide some basic conversion constants for the main Tempos.
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Hey all! While transcribing some music sheet (game music) I&#39;ve seen that the tempo was
somewhat strange and it wasn&#39;t due only to the deformation of my poor loudspeaker.
Indeed, our past sketches for playing tone music on Arduino (see the basic program
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;here&lt;/a&gt; and its advanced version &lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;here&lt;/a&gt;) are based on a fixed Tempo which is approx 90 crotchets
per minute. This is the same for all other sketches that I could find on the web.
&lt;br /&gt;
Therefore, here is a simple sketch function which changes the Tempo in your melody.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The sketch&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The code below contain just one function. Call it with your own tempo value or choose
one constant among those provided in the next section. The formula to compute the transformation takes into account the pause that we put between a note and the following
which was useful to distinguish the notes (this was set to 130% of the note duration
in our previous programs). Whenever the duration is not standard (in the case of an augmentation for example), a simple approximation formula is used.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Warning:&lt;/span&gt; some older version of melodies that you can find
over the net use &lt;code&gt;const int noteDurations[]&lt;/code&gt; as data type. Of course, you should change this
into &lt;code&gt;uint16_t noteDurations[]&lt;/code&gt; to be able to use the &lt;code&gt;setTempo()&lt;/code&gt; routine.
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid #e0efef; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;durations.h&quot;&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define INTERNOTE_PAUSE 1.3&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setTempo&lt;/span&gt;(&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; durs[], &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; tempo, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; istart, &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; iend) {
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;register&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; i;
  &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt; base;
  
  base &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt;)(&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1000.0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;((tempo&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;60.0&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;(&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;INTERNOTE_PAUSE)));
  
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt;(i&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;istart; i&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;iend; i&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;) {
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;switch&lt;/span&gt;(durs[i]) {
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_SEMIBREVE: 
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_MINIM: 
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_CROTCHET: 
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_QUAVER:
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;1&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_SEMIQUAVER:
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;2&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_DEMISEMIQUAVER:
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;3&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;case&lt;/span&gt; DUR_HEMIDEMISEMIQUAVER:
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; base &lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #997700; font-weight: bold;&quot;&gt;default:&lt;/span&gt;
        durs[i] &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;uint16_t&lt;/span&gt;)(durs[i]&lt;span style=&quot;color: #333333;&quot;&gt;/&lt;/span&gt;(DUR_CROTCHET&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1.0&lt;/span&gt;)&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;base);
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;break&lt;/span&gt;;      
    }
  }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The tempos&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In most of the music sheets, the tempo is indicated a phrase or a word (usually in Italian) and the interpretation of such words/phrases is often a matter of taste or of long discussions. Along with the previous sketch, below you can find &lt;code&gt;Tempos.h:&lt;/code&gt; my personal interpretation of most known tempos.
&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid #e0efef; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  Tempos.h&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  This is part of PlayMelodyAdv projet&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  A more advanced program for playing melodies on Arduino.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  Written by Enrico Formenti, 22 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#ifndef _Tempos_h&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define _Tempos_h&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LARGHISSIMO 24&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_GRAVE 32&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LENTISSIMO 40&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LENTO 46&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LARGO 50&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ADAGISSIMO 52&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LARGHETTO 56&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_LENTO 60&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ADAGIO 70&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ADAGIETTO 76&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ANDANTE 88&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_MODERATO 100&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ALLEGRETTO 116&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ALLEGRO 130&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_VIVACE 140&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_VIVACISSIMO 152&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ALLEGRISSIMO 160&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_ALLEGRO_VIVACE 160&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_PRESTO 170&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#define TEMPO_PRESTISSIMO 188&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#endif&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;See also&lt;/b&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;Tone music surprises!&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;Tone music: advanced playing software&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html&quot;&gt;Tone music: how to encode songs&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;
&lt;b&gt;Credits&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The image opening this post comes from &lt;a href=&quot;http://wikipedia.com/&quot;&gt;Wikipedia.com&lt;/a&gt;&lt;/div&gt;
</description><link>https://macduino.blogspot.com/2014/12/tone-music-changing-tempo.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzPO3qkW3um3ZHb_6YtqLIk1kRq4xG8kJCdKTNT3lFzuBGHbblJv2bjUgp3OcapxNtVQF41ZCSj-2oInMn3eey6L0hWpksDYQYFCHhBUPfaTohqCVAp5zqucKMXos7OrkY2pJ_D_gGaBg/s72-c/2000px-MozartExcerptK331.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-4384945854706056602</guid><pubDate>Mon, 22 Dec 2014 09:08:00 +0000</pubDate><atom:updated>2014-12-25T08:19:21.106+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">arduino music</category><category domain="http://www.blogger.com/atom/ns#">arduino sound</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">music</category><category domain="http://www.blogger.com/atom/ns#">tone music</category><title>Tone music: advanced playing software</title><description>&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 80%;&quot;&gt;
&lt;b&gt;Abstract&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this post we are going to present a more sophisticated program for playing melodies
on your Arduino. It allows you to encode repetitions and alternate endings, compacting
your longer melodies.
&lt;/div&gt;
&lt;b&gt;Keywords:&lt;/b&gt; tone music; pauses; augmentations; ties; repetitions. 
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The new playing routine&lt;/b&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
The new play function implements more sophisticated management of melodies allowing
pauses, ties, augmentations (like the past routine) and it also introduces the possibility
to use repetitions and alternate endings. &lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html&quot;&gt;This&lt;/a&gt; post explains how to encode all this.
&lt;br /&gt;&lt;br/&gt;
The sketch with the new routine is given below. Remark that it makes use of a support class
that implements a simple stack. Source files can found here: &lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_U0ZKRkhON2dJbGM/view?usp=sharing&quot;&gt;Stack.h&lt;/a&gt;, &lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_Q281b3d3YXY4Z1E/view?usp=sharing&quot;&gt;Stack.cpp&lt;/a&gt;. In order
to be able to compile the sketch you should open this two files in other tabs of your Arduino
IDE. You also need &lt;a href=&quot;https://drive.google.com/file/d/0B9uM_EGS3kp_ckROb1VFcjI3eFE/view?usp=sharing&quot;&gt;instructions.h&lt;/a&gt; which contains the encoding for the new instructions used
to encode the melodies.
&lt;/div&gt;
&lt;br/&gt;
&lt;b&gt;Compatibility&lt;/b&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
All the songs encoded for the previous version of the playing routine still work for this
new version without any modification. Indeed, the new melody encoding is an extension of
the older one.
&lt;/div&gt;
&lt;br/&gt;
&lt;b&gt;See also&lt;/b&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;Tone music surprises!&lt;/a&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html&quot;&gt;Tone music: how to encode songs&lt;/a&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-changing-tempo.html&quot;&gt;Tone music: changing the Tempo of your melodies&lt;/a&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .1em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #888888&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  PlayMelodyAdv&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  A more advanced program for playing melodies on Arduino. &lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  Define the label DEBUG to have some debug support&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  Written by Enrico Formenti, 22 dec 2014&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  BSD license, check the License page on the blog for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  All this text must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;pitches.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;durations.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;instructions.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;Stack.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;Stack.cpp&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799&quot;&gt;#include &amp;quot;SilentNight.h&amp;quot;&lt;/span&gt;
 
&lt;span style=&quot;color: #557799&quot;&gt;#define TONEPIN 8&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;struct&lt;/span&gt; {
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;struct&lt;/span&gt; {
  &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; N;  &lt;span style=&quot;color: #888888&quot;&gt;// position in melody array&lt;/span&gt;
  &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; D;  &lt;span style=&quot;color: #888888&quot;&gt;// position in durations array&lt;/span&gt;
  } I;         &lt;span style=&quot;color: #888888&quot;&gt;// individual addressing&lt;/span&gt;
  &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint32_t&lt;/span&gt; A;  &lt;span style=&quot;color: #888888&quot;&gt;// addressing all together&lt;/span&gt;
} POS;

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;playMusic&lt;/span&gt;( &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #333333&quot;&gt;*&lt;/span&gt;instr, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #333333&quot;&gt;*&lt;/span&gt;durs, &lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; len) {

  POS coda;      &lt;span style=&quot;color: #888888&quot;&gt;// address of coda symbol&lt;/span&gt;
  POS segno;     &lt;span style=&quot;color: #888888&quot;&gt;// address of segno symbol&lt;/span&gt;
  POS invRepeat; &lt;span style=&quot;color: #888888&quot;&gt;// position of inv repeat sign&lt;/span&gt;
  POS nskip;     &lt;span style=&quot;color: #888888&quot;&gt;// posistion of the first note to skip&lt;/span&gt;
  POS fine;      &lt;span style=&quot;color: #888888&quot;&gt;// end of music symbol position&lt;/span&gt;
  POS askip;     &lt;span style=&quot;color: #888888&quot;&gt;// position of the first note to skip in alternate ending&lt;/span&gt;
  POS curPos; 

  &lt;span style=&quot;color: #888888&quot;&gt;// reset all internal variables&lt;/span&gt;
  coda.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  segno.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  invRepeat.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  nskip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  fine.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  askip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
  
  &lt;span style=&quot;color: #888888&quot;&gt;// start looping&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;while&lt;/span&gt;(curPos.I.N &lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt; len) {
    Stack&lt;span style=&quot;color: #333333&quot;&gt;&amp;lt;&lt;/span&gt;POS&lt;span style=&quot;color: #333333&quot;&gt;&amp;gt;&lt;/span&gt; reps; &lt;span style=&quot;color: #888888&quot;&gt;// make the stack local so it is emptied when the loop &lt;/span&gt;
                     &lt;span style=&quot;color: #888888&quot;&gt;// is over&lt;/span&gt;

    &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;switch&lt;/span&gt;(instr[curPos.I.N]) {
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_PAUSE:
        &lt;span style=&quot;color: #888888&quot;&gt;// noTone(TONEPIN);&lt;/span&gt;
        delay(durs[curPos.I.D]);
        curPos.A &lt;span style=&quot;color: #333333&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x11&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_CODA:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(nskip.A) {
          curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; nskip.A;
          nskip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          coda.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        coda.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; curPos.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// start from next position&lt;/span&gt;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DACAPO:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(reps.isEmpty() &lt;span style=&quot;color: #333333&quot;&gt;||&lt;/span&gt; (reps.topElement().A&lt;span style=&quot;color: #333333&quot;&gt;!=&lt;/span&gt;curPos.A)) { &lt;span style=&quot;color: #888888&quot;&gt;// if this event has not already occurred&lt;/span&gt;
          reps.push(curPos); &lt;span style=&quot;color: #888888&quot;&gt;// add this event&lt;/span&gt;
          curPos.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;  &lt;span style=&quot;color: #888888&quot;&gt;// repeat from the beginning&lt;/span&gt;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// otherwise we simply skip and update the instruction pointer&lt;/span&gt;
        reps.pop();
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_SEGNO:
        segno.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;curPos.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// start from next position in note array&lt;/span&gt;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;        
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_REPEAT:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(reps.isEmpty() &lt;span style=&quot;color: #333333&quot;&gt;||&lt;/span&gt; (reps.topElement().A &lt;span style=&quot;color: #333333&quot;&gt;!=&lt;/span&gt; curPos.A)) {
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(invRepeat.A) { &lt;span style=&quot;color: #888888&quot;&gt;// repeat from last inv repeat sign if any&lt;/span&gt;
            curPos.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;invRepeat.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x11&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// add +1 to both N and D pointers&lt;/span&gt;
            invRepeat.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
            reps.push(curPos);&lt;span style=&quot;color: #888888&quot;&gt;// push the event on the stack&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
          }
          &lt;span style=&quot;color: #888888&quot;&gt;// otherwise repeat from the beginning&lt;/span&gt;
          reps.push(curPos);&lt;span style=&quot;color: #888888&quot;&gt;// push the event on the stack&lt;/span&gt;
          curPos.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// if this is the sign that issued the event&lt;/span&gt;
        reps.pop();
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_INVREPEAT:
        invRepeat.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;curPos.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// start from the next position in notes array&lt;/span&gt;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DALSEGNO:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(reps.isEmpty() &lt;span style=&quot;color: #333333&quot;&gt;||&lt;/span&gt; (reps.topElement().A&lt;span style=&quot;color: #333333&quot;&gt;!=&lt;/span&gt;curPos.A)) { &lt;span style=&quot;color: #888888&quot;&gt;// if this has not generated the event&lt;/span&gt;
          reps.push(curPos);
          curPos.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;segno.A;
          segno.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// otherwise skip and update N only&lt;/span&gt;
        reps.pop();
        segno.A&lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DALSEGNOCODA:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(reps.isEmpty() &lt;span style=&quot;color: #333333&quot;&gt;||&lt;/span&gt; (reps.topElement().A&lt;span style=&quot;color: #333333&quot;&gt;!=&lt;/span&gt;curPos.A)) {
          reps.push(curPos);
          curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; segno.A;
          segno.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          nskip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; coda.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// otherwise skip and update N only&lt;/span&gt;
        reps.pop();
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DACAPOCODA:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(reps.isEmpty() &lt;span style=&quot;color: #333333&quot;&gt;||&lt;/span&gt; (reps.topElement().A&lt;span style=&quot;color: #333333&quot;&gt;!=&lt;/span&gt;curPos.A)) {
          reps.push(curPos);
          curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          segno.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          nskip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; coda.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// otherwise skip and update N only&lt;/span&gt;
        reps.pop();
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_FINE:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(fine.A) { &lt;span style=&quot;color: #888888&quot;&gt;// we already passed through the music end symbol&lt;/span&gt;
          curPos.I.N &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; len; &lt;span style=&quot;color: #888888&quot;&gt;// then stop playing&lt;/span&gt;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        fine.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; curPos.A;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DACAPOFINE:
        curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_DALSEGNOFINE:
        curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; segno.A;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_ALTBEGIN:
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;if&lt;/span&gt;(askip.A) { &lt;span style=&quot;color: #888888&quot;&gt;// we are repeating the sequence, hence skip&lt;/span&gt;
          curPos.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; askip.A;
          askip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000DD; font-weight: bold&quot;&gt;0&lt;/span&gt;;
          &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
        }
        &lt;span style=&quot;color: #888888&quot;&gt;// not repeating so just keep playing&lt;/span&gt;
        (curPos.I.N)&lt;span style=&quot;color: #333333&quot;&gt;++&lt;/span&gt;;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;case&lt;/span&gt; NOTE_ALTEND:
        askip.A &lt;span style=&quot;color: #333333&quot;&gt;=&lt;/span&gt; curPos.A&lt;span style=&quot;color: #333333&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x10&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// set the skip to the next instruction&lt;/span&gt;
                                 &lt;span style=&quot;color: #888888&quot;&gt;// so that it will be skipped during the&lt;/span&gt;
                                 &lt;span style=&quot;color: #888888&quot;&gt;// repetition&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;   
      &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color: #333333&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #888888&quot;&gt;// it is a note instruction&lt;/span&gt;
        tone(TONEPIN, instr[curPos.I.N], durs[curPos.I.D]);
        &lt;span style=&quot;color: #888888&quot;&gt;// to distinguish the notes, set a minimum time between them.&lt;/span&gt;
        &lt;span style=&quot;color: #888888&quot;&gt;// the note&amp;#39;s duration + 30% seems to work well:&lt;/span&gt;
        delay(durs[curPos.I.D] &lt;span style=&quot;color: #333333&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #6600EE; font-weight: bold&quot;&gt;1.3&lt;/span&gt;);
        &lt;span style=&quot;color: #888888&quot;&gt;// stop the tone playing:&lt;/span&gt;
        noTone(TONEPIN);
        curPos.A &lt;span style=&quot;color: #333333&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #005588; font-weight: bold&quot;&gt;0x11&lt;/span&gt;; &lt;span style=&quot;color: #888888&quot;&gt;// update both N and D pointers&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold&quot;&gt;break&lt;/span&gt;;
    }
  }
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;setup&lt;/span&gt;() {
  
&lt;span style=&quot;color: #557799&quot;&gt;#ifdef DEBUG&lt;/span&gt;
  Serial.begin();
&lt;span style=&quot;color: #557799&quot;&gt;#endif&lt;/span&gt;
  
  playMusic((&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #333333&quot;&gt;*&lt;/span&gt;)melody,(&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt; &lt;span style=&quot;color: #333333&quot;&gt;*&lt;/span&gt;)noteDurations,(&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;uint16_t&lt;/span&gt;)melody_len);  
}

&lt;span style=&quot;color: #333399; font-weight: bold&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066BB; font-weight: bold&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888&quot;&gt;// no need to repeat the melody.&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;</description><link>https://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html</link><author>noreply@blogger.com (Maczinga)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-4120977403986469086</guid><pubDate>Mon, 22 Dec 2014 09:08:00 +0000</pubDate><atom:updated>2015-01-01T11:36:04.202+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">arduino music</category><category domain="http://www.blogger.com/atom/ns#">arduino sound</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">buzzer music</category><category domain="http://www.blogger.com/atom/ns#">tone music</category><title>Tone music: how to encode songs</title><description>&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvNYvb-X_ksCamCUlEl1mrFC1rv4GJkITLQKCEGW0szj4xaaS6gy5S-NFXqm31-xiyQfOTSDuryyZBiiPu-fNtLkwKUdFxj8PbFlhFhEMhTl_gXtUKVcTY82Hc_xz9AavUI1F2ly_8Jqk/s1600/sheet-music-notes-and-symbols-w540.png&quot; style=&quot;border-radius: 8px;&quot; /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 80%;&quot;&gt;
&lt;b&gt;Abstract&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this article we explain how to encode tone music for your Arduino projects. In particular,
we explain how to encode pauses, ties, repetitions, etc. This new encoding extends the one
we have proposed in a past post. The main advantage is that it can considerably shorten
melodies physical description and hence save memory space.
&lt;/div&gt;
&lt;b&gt;Keywords:&lt;/b&gt; tone music; pauses; augmentations; ties; repetitions. 
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Which music sheets to use?&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It is not clear which sheets translate better into tone music. I prefer to use easy piano
music sheets, or simply start from scratch by trials and errors.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Basic encoding&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Encoding a music sheet essentially consists in defining the following three objects:
&lt;br /&gt;
&lt;table style=&quot;border-spacing: 2px 16px;&quot;&gt;
&lt;tbody&gt;
&lt;tr style=&quot;vertical-align: top;&quot;&gt;
&lt;td&gt;&lt;code&gt;uint16_t instr_len&lt;/code&gt;:&lt;/td&gt;&lt;td&gt;this is the length of the array &lt;code&gt;melody&lt;/code&gt;.
Remark that the size of a melody is limited by the size of &lt;code&gt;int&lt;/code&gt;. This is not a true limitation since this is far beyond the memory capabilities of Arduino Uno.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;vertical-align: top;&quot;&gt;
&lt;td&gt;&lt;code&gt;uint16_t instr[]&lt;/code&gt;:&lt;/td&gt;&lt;td&gt;array containing the instructions for playing the melody&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;vertical-align: top;&quot;&gt;
&lt;td style=&quot;width: 30%;&quot;&gt;&lt;code&gt;uint16_t durs[]&lt;/code&gt;:&lt;/td&gt;&lt;td&gt;array containing the instructions for the duration of the current note or of the current pause.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Encoding pauses&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pauses are encoded similarly to notes. Indeed, one has to add &lt;code&gt;NOTE_PAUSE&lt;/code&gt; instruction in the &lt;code&gt;melody&lt;/code&gt; array and adding the corresponding duration in
the &lt;code&gt;noteDurations&lt;/code&gt; array.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Encoding augmentations&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
An augmentation is graphically represented by a dot which follows a note and it is meant
to augment the duration of the note by one half. Therefore, to encode a note with an
augmentation it is enough to encode the value of the pitch as usual; in the &lt;code&gt;durs&lt;/code&gt; array we will add the note duration plus the duration of its half. For example, considering
the situation in Figure 1, one would add &lt;code&gt;NOTE_RE4&lt;/code&gt; to the &lt;code&gt;instr&lt;/code&gt;
array and &lt;code&gt;DUR_MINIM+DUR_CROTCHET&lt;/code&gt; to the &lt;code&gt;durs&lt;/code&gt; array.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRFHNDXfmpQ5POUt4kXK77YCdbPKHVXqiHkkdeMKxnft7ApI95EVT_JhEB9DpueqR0ApM3q81beES4UsoBohCdFo9FTY4jFGsARCEze4jCsn-U4I3hasUrX6NEBV3HuYky-HrMTpJmJxY/s1600/note-augmentation.png&quot; height=&quot;88&quot; width=&quot;124&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. Example of an augmentation.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;Encoding ties&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
A tie is a symbol which connects two notes or three notes of the same pitch. Even if the two (or three) notes have different durations, their tie should be played as if it was a unique note with a duration which is the sum of the durations of the composing notes. For example, the tie in Figure 2 is encoded by adding &lt;code&gt;NOTE_SOL3&lt;/code&gt; in the &lt;code&gt;melody&lt;/code&gt; array and
&lt;code&gt;DUR_MINIM+DUR_SEMIBREVE&lt;/code&gt; in the &lt;code&gt;noteDurations&lt;/code&gt; array.
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq4td8embUa33Bd6JRoSBoyOdQd48Hv11Ajdf2j-IUUkmOrIvjEXaimSAusZuCO-zGwACy5YVxSaMVuL1wGhDziMobm0kaadM4B8n9xrZv3bXRtOsafSyaxXCep30OL7HQY2T267AhZsQ/s1600/music-tie.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq4td8embUa33Bd6JRoSBoyOdQd48Hv11Ajdf2j-IUUkmOrIvjEXaimSAusZuCO-zGwACy5YVxSaMVuL1wGhDziMobm0kaadM4B8n9xrZv3bXRtOsafSyaxXCep30OL7HQY2T267AhZsQ/s1600/music-tie.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 2. Example of tie.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Encoding repetitions&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Repetitions are a bit complicated and consists in some symbols and some Italian phrases. If
you are not familiar with them you can learn more in &lt;a href=&quot;http://www.piano-lessons-made-simple.com/repeat-sign.html&quot;&gt;this&lt;/a&gt; excellent tutorial. We implemented all repetition types
and symbols. In order to add a repetition one just needs to add its corresponding encoding
to the &lt;code&gt;instr&lt;/code&gt; array and nothing to the &lt;code&gt;durs&lt;/code&gt; array. The coding for
the coda symbol (&lt;code&gt;NOTE_CODA&lt;/code&gt;) has to be inserted right before to the note that it refers to. Here is a table of the repetitions sign/phrases and their corresponding encoding.
&lt;/div&gt;
&lt;br /&gt;
&lt;table style=&quot;border-spacing: 40px 2px; margin-left: auto; margin-right: auto;&quot;&gt;
&lt;thead style=&quot;background-color: #e0efef; font-weight: bold; text-align: center;&quot;&gt;
&lt;tr&gt;&lt;td&gt;Symbol/Phrase&lt;/td&gt;&lt;td&gt;Encoding&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Repeat&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_REPEAT&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Inverse repeat&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_INVREPEAT&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Coda&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_CODA&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Da capo (DC)&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DACAPO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Da capo a coda&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DACAPOCODA&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Segno&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_SEGNO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Dal segno (DS)&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DALSEGNO&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Dal segno a coda&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DALSEGNOCODA&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Fine&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_FINE&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Da capo a fine (DC fine)&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DACAPOFINE&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;padding-left: 6px;&quot;&gt;Dal segno a fine (DS fine)&lt;/td&gt;&lt;td style=&quot;font-family: monospace; padding-left: 6px;&quot;&gt;NOTE_DALSEGNOFINE&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red; font-weight: bold;&quot;&gt;Warning:&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In order to get a code as short as possible no effort is made to check if the sequence of
repetition symbols/phrases is correct (for example, if a &lt;code&gt;NOTE_DACAPO&lt;/code&gt; is preceded by a &lt;code&gt;NOTE_CAPO&lt;/code&gt;). In the case of incorrect encoding the behavior is unpredictable.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Alternate endings&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The program allows to encode alternate ending by putting the instruction &lt;code&gt;NOTE_ALTBEGIN&lt;/code&gt; at the beginning of the alternate ending and &lt;code&gt;NOTE_ALTEND&lt;/code&gt; at the end. You may add as many alternate ending as needed.
The instruction &lt;code&gt;NOTE_ALTEND&lt;/code&gt; has to be omitted for the very last one. 
For example, considering the situation in Figure 3, one should have encoded
&lt;br /&gt;
&lt;pre&gt;      ..., NOTE_ALTBEGIN, ..., NOTE_ALTEND, NOTE_ALTBEGIN, ...
&lt;/pre&gt;
Remark that
in order to keep the code as simple (and compact) as possible, the technique described here
allows to describe only &quot;linear&quot; ending sequences. Indeed, in complex music sheets you may
find several endings by groups, for example one should play the first ending, the second;
then the first one again, followed by the second one, etc. In such complicated case, you should &quot;unroll&quot; the music yourself by duplicating some parts.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDg9d7yjgUX0ObdJ1rIf4JovjaqVF3dhoaIat7vh6E6s4gYh8l0wasN5FVykSf5RTn4dMK9pQTYooskZ4MacAXxwNn3_gxFHCsLVlXJHulV_EFpy575Su9xJBTBlZ5ILl-SqXBpFgw0ng/s1600/music-alternate-ending.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDg9d7yjgUX0ObdJ1rIf4JovjaqVF3dhoaIat7vh6E6s4gYh8l0wasN5FVykSf5RTn4dMK9pQTYooskZ4MacAXxwNn3_gxFHCsLVlXJHulV_EFpy575Su9xJBTBlZ5ILl-SqXBpFgw0ng/s1600/music-alternate-ending.png&quot; height=&quot;169&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 3. Example of alternate ending.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;Encoding chords&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Another difficulty is to encode chords. Indeed, due to the limited capabilities of the
speaker, the best and quickest way to encode chords is by encoding just the fundamental
note of the chord and forget about the others (recall that the fundamental note of a chord
is normally the one that is at the bottom of the chord). Figure 4 illustrates this idea.
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVOOSOoKytiWX3xZoB35d5aFImiChUYhZN8cwRYv2uVFrbv9DH_fVl5r0bgiL2Wv_RJ_3JqDqyLNkG-F75sM5rsQ6VbCYcKFnJABzWyRjJNgIn1mizMM2xTsHdPTqQ63mhKWMu5vDyhoI/s1600/EncodeChords.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVOOSOoKytiWX3xZoB35d5aFImiChUYhZN8cwRYv2uVFrbv9DH_fVl5r0bgiL2Wv_RJ_3JqDqyLNkG-F75sM5rsQ6VbCYcKFnJABzWyRjJNgIn1mizMM2xTsHdPTqQ63mhKWMu5vDyhoI/s320/EncodeChords.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 4. Illustration of how to encode chords.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;See also&lt;/b&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-surprises.html&quot;&gt;Tone music surprises!&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;
Tone music: advanced playing software&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-changing-tempo.html&quot;&gt;Tone music: changing the Tempo of your melodies&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;</description><link>https://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvNYvb-X_ksCamCUlEl1mrFC1rv4GJkITLQKCEGW0szj4xaaS6gy5S-NFXqm31-xiyQfOTSDuryyZBiiPu-fNtLkwKUdFxj8PbFlhFhEMhTl_gXtUKVcTY82Hc_xz9AavUI1F2ly_8Jqk/s72-c/sheet-music-notes-and-symbols-w540.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-1729372069798240818</guid><pubDate>Wed, 17 Dec 2014 23:25:00 +0000</pubDate><atom:updated>2018-06-09T09:10:37.182+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo</category><category domain="http://www.blogger.com/atom/ns#">FM Stereo module</category><category domain="http://www.blogger.com/atom/ns#">LCD Module</category><category domain="http://www.blogger.com/atom/ns#">Modules</category><category domain="http://www.blogger.com/atom/ns#">MR007-005.1</category><category domain="http://www.blogger.com/atom/ns#">TEA5767</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HL</category><category domain="http://www.blogger.com/atom/ns#">TEA5767HN</category><category domain="http://www.blogger.com/atom/ns#">TEA5768</category><category domain="http://www.blogger.com/atom/ns#">TEA5768HL</category><title>FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757)(Part 1/4)</title><description>&lt;h4&gt;Abstract&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this post we are going to play with an FM Radio module based on TEA5767 chip (for TEA5768 the only difference is at the bus level, we will made this precise when writing the source code).The module is essentially based on the TEA5767 to which is adds a small stereo amplifier and a connector for headphones. Indeed, the output level of TEA5767 is very weak and one needs an amplifier to make a serious use out of it. As usual we will explain both hardware and software aspects. However, since the article is pretty long, we split it into two parts.
In this first part, we look more closely at the hardware aspects. The second part
will provide
some useful functions and it will be assorted of interesting application examples. In the examples, we use the usual LCD module based on the classical 1602 LCD screen which accompanies many Arduino experiments.&lt;br /&gt;
&lt;br /&gt;
&lt;style&gt;
.abs-divider {
width:90%;
color:#006699;
background-color:#006699;
height:3px;
}
.abs-divider-small {
width:90%;
color:#006699;
background-color:#006699;
height:2px;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;hr class=&quot;abs-divider&quot; /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;Table of contents (part 1)&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-size: 12px; margin-bottom: 10px; margin-left: auto; margin-right: auto; width: 82%;&quot;&gt;
&lt;div style=&quot;border-right: 1px solid black; float: left; margin-bottom: 10px; padding-right: 10px;&quot;&gt;
&lt;a href=&quot;#FM-module&quot;&gt;The FM stereo module&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#67vs68&quot;&gt;TEA5767 vs. TEA5768&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#datasheets&quot;&gt;Datasheets&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#pin-out&quot;&gt;Module pinout&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#antenna&quot;&gt;The antenna&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#basic-op&quot;&gt;Basic operation&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#write-seq&quot;&gt;Write sequence&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;border-right: 1px solid black; float: left; padding-left: 10px; padding-right: 10px;&quot;&gt;
&lt;a href=&quot;#write-seq-default&quot;&gt;Write sequence defaults&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#read-seq&quot;&gt;Read sequence&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#read-seq-default&quot;&gt;Read sequence defaults&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#search-mode&quot;&gt;Search mode&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#pll-register&quot;&gt;The PLL register&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#side-injection&quot;&gt;Side injection&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#soft-ports&quot;&gt;Software ports&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;float: left; margin-bottom: 10px; padding-left: 10px;&quot;&gt;
&lt;a href=&quot;#band-limits&quot;&gt;Band limits&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#clock-frequency&quot;&gt;Clock frequency&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#soft-mute&quot;&gt;Software mute&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#high-control-cut&quot;&gt;High control cut&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#stereo-noise-cancelling&quot;&gt;Stereo noise cancelling&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#de-emphasis-time-constant&quot;&gt;De-emphasis time constant&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;#alternate&quot;&gt;Alternate modules&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr class=&quot;abs-divider-small&quot; /&gt;
&lt;div style=&quot;width:82%;font-size:x-small;margin-left:auto;margin-right:auto&quot;&gt;
&lt;span style=&quot;color:red;font-weight:bold&quot;&gt;Warning:&lt;/span&gt;
Click on the &quot;more&quot; button below to be able to fully exploit the links in the list above.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;FM-module&quot;&gt;The FM stereo module&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The module is represented in Figure 1. Indeed, it is essentially a &quot;decoration&quot; for the TEA5767 module which can be seen in the central part of the picture. Figure 2 zooms on the TEA5767 module.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjimagfNTuxSFlJT7om9O7TdRc-4-71T0q1FIdIC_ed78ZRFpgk1bCtu90RuAgpVB5vvwd98zHmq2mhJC6a-TASJOWjC7rdHuOdSdc4vySaa1petY1t8-ts5OHZ0nzhdzijSUHT1JbXbQA/s1600/FM-Stereo-Module.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjimagfNTuxSFlJT7om9O7TdRc-4-71T0q1FIdIC_ed78ZRFpgk1bCtu90RuAgpVB5vvwd98zHmq2mhJC6a-TASJOWjC7rdHuOdSdc4vySaa1petY1t8-ts5OHZ0nzhdzijSUHT1JbXbQA/s1600/FM-Stereo-Module.jpg&quot; height=&quot;172&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. The FM stereo module for Arduino.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg2t51G75azX63fBbajHrzDr9aGog58csR-0f-M-ewyWEWWpJWMjDvc1V9jGFS-6Uh2z6enp_UDo9Tm2or8eOcgN8e7sTPCY3_CG0AbnCEmEiX7UJWTP_9wuxh0elmp8yKk5Htx00F3Rw/s1600/TEA5767.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg2t51G75azX63fBbajHrzDr9aGog58csR-0f-M-ewyWEWWpJWMjDvc1V9jGFS-6Uh2z6enp_UDo9Tm2or8eOcgN8e7sTPCY3_CG0AbnCEmEiX7UJWTP_9wuxh0elmp8yKk5Htx00F3Rw/s1600/TEA5767.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 2. TEA5767 module.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h4 id=&quot;67vs68&quot;&gt;TEA5767 vs. TEA5768&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Essentially TEA5767 and TEA5768 differ for the set of communication protocols that they support and/or the packaging; all other characteristics are identical. There are three 
models:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;TEA5767HN: FM stereo radio, 40 leads with I2C and 3-Wire bus. Body 6*6*0.85 mm,
SOT1618 package.&lt;/li&gt;
&lt;li&gt;TEA5767HL: FM stereo radio, 32 leads with 3-Wire bus. Body: 7*7*1.4 mm, SOT358
package.
&lt;/li&gt;
&lt;li&gt;TEA5768HL: FM stereo radio, 32 leads with I2C bus. Body: 7*7*1.4 mm, 
SOT358 package.&lt;/li&gt;
&lt;/ul&gt;
In the second part of this article, we will specialize the read/write function according to
the model used.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;datasheets&quot;&gt;Datasheets&lt;/h4&gt;
&lt;div&gt;
&lt;table style=&quot;padding-left: 15px; padding-top: 5px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_eWVIaUpnMFh1REE&amp;amp;authuser=0&quot;&gt;TEA5767HN&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Revision 2007.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_Qnp3ZHdKb1d2MWc&amp;amp;authuser=0&quot;&gt;TEA5767HN&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Revision 2003.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_S1NDTkZmT3pfWUE&amp;amp;authuser=0&quot;&gt;TEA5767HL&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Revision 2004.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_ZlhsNk5PRTJkU1k&amp;amp;authuser=0&quot;&gt;TEA5768HL&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Revision 2008 (indeed identical to rev. 2003).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_T2ctVFE3SWNsQ1k&amp;amp;authuser=0&quot;&gt;TEA5768HL&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Revision 2003.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_R3dvN2toZUZndTQ&amp;authuser=0&quot;&gt;
AN10133&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Application note for TEA5767/TEA5768.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_MEJSMlNsUGhrLXM&amp;amp;authuser=0&quot;&gt;TEA576X&lt;/a&gt;&lt;/td&gt;&lt;td&gt;Brochure.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;pin-out&quot;&gt;The pin out&lt;/h4&gt;
The pins are pretty well signalled on the module and should be connect to your Arduino as follows&lt;br /&gt;
&lt;br /&gt;
&lt;style&gt;
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; } .datagrid {font: normal 12px/150% Verdana, Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.datagrid table td, .datagrid table th { padding: 3px 10px; }.datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=&#39;#006699&#39;, endColorstr=&#39;#00557F&#39;);background-color:#006699; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 1px solid #0070A8; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.datagrid table tbody .alt td { background: #E1EEF4; color: #00496B; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Module&lt;/th&gt;&lt;th&gt;Uno&lt;/th&gt;&lt;th&gt;Mega&lt;/th&gt;&lt;th&gt;Leonardo&lt;/th&gt;&lt;th&gt;Due&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;SDA&lt;/td&gt;&lt;td&gt;A4&lt;/td&gt;&lt;td&gt;20&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;20 or SDA1&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;SCL&lt;/td&gt;&lt;td&gt;A5&lt;/td&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;21 or SCL1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;GND&lt;/td&gt;&lt;td&gt;GND&lt;/td&gt;&lt;td&gt;GND&lt;/td&gt;&lt;td&gt;GND&lt;/td&gt;&lt;td&gt;GND&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;Vcc&lt;/td&gt;&lt;td&gt;+5V&lt;/td&gt;&lt;td&gt;+5V&lt;/td&gt;&lt;td&gt;+5V&lt;/td&gt;&lt;td&gt;+5V&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ANT&lt;/td&gt;&lt;td colspan=&quot;4&quot;&gt;Antenna, see the dedicated section.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;antenna&quot; &gt;The antenna&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If you don&#39;t have an antenna then you can easily build one by yourself. For example, in my experiments I&#39;ve just used a 30cm long cable with female Dupont endpoints. Of course, this is not very efficient. Better results can be obtained with cables of length proportional to the length of the FM wave. Usually they use 1/4 or 1/2 of the length of the 100MHz wave that is 713mm or 1416mm, respectively. For even better reception one can build a dipole antenna, many instructions for that can be found over the internet, for example &lt;a href=&quot;http://www.radiobrandy.com/dipole1.html&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;h4 id=&quot;basic-op&quot;&gt;Basic operation&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The module communicates with the Arduino via the I2C bus. Its unique address is 0x60. Commands are sent on the I2C bus and consists of a 5 bytes sequence. The sequence is different according to read or write operations. Therefore a basic command sequence is as follows.
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;Wire.beginTransmission(&lt;span style=&quot;color: #005588; font-weight: bold;&quot;&gt;0x60&lt;/span&gt;);   &lt;span style=&quot;color: #888888;&quot;&gt;// address of TEA5767 module&lt;/span&gt;
                                &lt;span style=&quot;color: #888888;&quot;&gt;// on the I2C bus&lt;/span&gt;
                                
  Wire.write( byte1 );
  Wire.write( byte2 );
  Wire.write( byte3 );
  Wire.write( byte4 );
  Wire.write( byte5 );

Wire.endTransmission();
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
At power on both the left and right channels are muted. Both the frequency of the receiver
and the configurations bytes must be provided. No default power-on configuration is provided.&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;write-seq&quot;&gt;Write sequence&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It is used to configure the FM receiver and consists of 5 bytes with the following meaning.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 1&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;MUTE&lt;/td&gt;&lt;td&gt;MUTE=1 then both L and R channels are muted. MUTE=0 then
L and R channels are not muted.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;SM&lt;/td&gt;&lt;td&gt;If SM=1 then search mode is enabled, disabled otherwise. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#search-mode&quot;&gt;here&lt;/a&gt; for more details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;PLL13&lt;/td&gt;&lt;td&gt;14th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;PLL12&lt;/td&gt;&lt;td&gt;13th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;PLL11&lt;/td&gt;&lt;td&gt;12th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;PLL10&lt;/td&gt;&lt;td&gt;11th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PLL09&lt;/td&gt;&lt;td&gt;10th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;PLL08&lt;/td&gt;&lt;td&gt;9th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 2&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;PLL07&lt;/td&gt;&lt;td&gt;8th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;PLL06&lt;/td&gt;&lt;td&gt;7th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;PLL05&lt;/td&gt;&lt;td&gt;6th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;PLL04&lt;/td&gt;&lt;td&gt;5th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;PLL03&lt;/td&gt;&lt;td&gt;4th bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;PLL02&lt;/td&gt;&lt;td&gt;3rd bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PLL01&lt;/td&gt;&lt;td&gt;2nd bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;PLL00&lt;/td&gt;&lt;td&gt;1st bit of the PLL word.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 3&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;SUD&lt;/td&gt;&lt;td&gt;If SUD=1 then search forward mode is activated, otherwise search backward is activated. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#search-mode&quot;&gt;this&lt;/a&gt; section for details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;SSL1&lt;/td&gt;&lt;td&gt;Search stop level MSB. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#search-mode&quot;&gt;this&lt;/a&gt; section for details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;SSL0&lt;/td&gt;&lt;td&gt;Search stop level LSB. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#search-mode&quot;&gt;this&lt;/a&gt; section for details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;HLSI&lt;/td&gt;&lt;td&gt;If HLSI=1, then high side injection is activated, otherwise low side injection is activated. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#side-injection&quot;&gt;here&lt;/a&gt; for details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;MS&lt;/td&gt;&lt;td&gt;If MS=1, then mono is forced, stereo otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;ML&lt;/td&gt;&lt;td&gt;If ML=1, then the left channel is muted, non-muted otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;MR&lt;/td&gt;&lt;td&gt;If MR=1, then the right channel is muted, non-muted otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;SWP1&lt;/td&gt;&lt;td&gt;If SWP1=1, then the software port 1 is HIGH, LOW otherwise. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#soft-port-1&quot;&gt;here&lt;/a&gt; for details.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 4&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;SWP2&lt;/td&gt;&lt;td&gt;If SWP2=1 then software port 2 is HIGH, LOW otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;STBY&lt;/td&gt;&lt;td&gt;If STBY=1, then stand-by mode is activated, unactivated otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;BL&lt;/td&gt;&lt;td&gt;If BL=1, then Japanese FM band is used, otherwise US/Europe FM band is used.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;XTAL&lt;/td&gt;&lt;td&gt;Clock frequency. See &lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=5076928765077392764#clock-frequency&quot;&gt;here&lt;/a&gt; for details.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;SMUTE&lt;/td&gt;&lt;td&gt;If SMUTE=1, then software mute is on, off otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;HCC&lt;/td&gt;&lt;td&gt;If HCC=1, then High Control Cut is on, off otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;SNC&lt;/td&gt;&lt;td&gt;If SNC=1, then Stereo Noise Canceling is on, off otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;SI&lt;/td&gt;&lt;td&gt;(Search Indicator) If SI=1, then the software port 1 is output for the ready flag, otherwise the SWP1 pin is software port 1.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 5&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;PLLREF&lt;/td&gt;&lt;td&gt;If PLLREF=1 then the 6.5MHz is used as reference frequency for the PLL, not used otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;DTC&lt;/td&gt;&lt;td&gt;(De-emphasis time constant) If DTC=1, then de-emphasis time constant is 75μS; 50μS otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;Unused.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;write-seq-default&quot;&gt;Write sequence defaults&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Being in Europe, then DTC=0 and BL=0. Moreover, as we have already seen, our module is clocked at 32768Hz and hence PLLREF=0 and XTAL=1. I would set also SWP2=0 since I&#39;ve not understood what is the usage of this bit.&lt;/div&gt;
&lt;br/&gt;
&lt;h4 id=&quot;read-seq&quot;&gt;Read sequence&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The read sequence allow to inquiry for the current FM station frequency, the Intermediate
Frequency and the level of reception of the current FM station. It consists of 5 bytes (like
the write sequence) which are detailed in the following tables.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 1&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;RF&lt;/td&gt;&lt;td&gt;If RF=1 then a station has been found or the band limit is reached, not station otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;BLF&lt;/td&gt;&lt;td&gt;If BLF=1, then the band limit is reached; unreached otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;PLL13&lt;/td&gt;&lt;td&gt;14th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;PLL12&lt;/td&gt;&lt;td&gt;13th bit of the PLL register&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;PLL11&lt;/td&gt;&lt;td&gt;12th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;PLL10&lt;/td&gt;&lt;td&gt;11th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PLL09&lt;/td&gt;&lt;td&gt;10th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;PLL08&lt;/td&gt;&lt;td&gt;9th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 2&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;PLL07&lt;/td&gt;&lt;td&gt;8th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;PLL06&lt;/td&gt;&lt;td&gt;7th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;PLL05&lt;/td&gt;&lt;td&gt;6th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;PLL04&lt;/td&gt;&lt;td&gt;5th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;PLL03&lt;/td&gt;&lt;td&gt;4th bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;PLL02&lt;/td&gt;&lt;td&gt;3rd bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PLL01&lt;/td&gt;&lt;td&gt;2nd bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;PLL00&lt;/td&gt;&lt;td&gt;1st bit of the PLL register.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 3&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;STEREO&lt;/td&gt;&lt;td&gt;If STEREO=1 then stereo reception, mono otherwise.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;PLL-IF6&lt;/td&gt;&lt;td&gt;Bit 7 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;PLL-IF05&lt;/td&gt;&lt;td&gt;Bit 6 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;PLL-IF04&lt;/td&gt;&lt;td&gt;Bit 4 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;PLL-IF03&lt;/td&gt;&lt;td&gt;Bit 3 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;PLL-IF02&lt;/td&gt;&lt;td&gt;Bit 2 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PLL-IF01&lt;/td&gt;&lt;td&gt;Bit 1 of IF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;PLL-IF00&lt;/td&gt;&lt;td&gt;Bit 0 ofIF counter result.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 4&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;7 (MSB)&lt;/td&gt;&lt;td&gt;LEV3&lt;/td&gt;&lt;td&gt;Bit 3 of ADC level output.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;LEV2&lt;/td&gt;&lt;td&gt;Bit 2 of ADC level output.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;LEV1&lt;/td&gt;&lt;td&gt;Bit 1 of ADC level output.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;LEV0&lt;/td&gt;&lt;td&gt;Bit 0 of ADC level output.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;CI3&lt;/td&gt;&lt;td&gt;Bit 3 of chip identification. Set to 0.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;CI2&lt;/td&gt;&lt;td&gt;Bit 2 of chip identification. Set to 0.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;CI1&lt;/td&gt;&lt;td&gt;Bit 1 of chip identification. Set to 0.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0 (LSB)&lt;/td&gt;&lt;td&gt;CI0&lt;/td&gt;&lt;td&gt;Bit 0 of chip identification. Set to 0.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot;&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Byte 5&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;[7:0] &lt;/td&gt;&lt;td&gt;UNUSED&lt;/td&gt;&lt;td&gt;Unused. Future purpose.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;read-seq-defaults&quot;&gt;Read sequence defaults&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
As recommended by the datasheet, first four bits of byte 4 must be set to 0. Byte 5 is set
to 0.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;search-mode&quot;&gt;Search mode&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
TEA5767 can search span the FM band searching for the next transmitting station. Search
mode is activated setting bit 7 of byte 1. The search direction is controlled by bit 7
of byte 3 (1 for forward, 0 for backward). The search is stopped when a station having a reception level higher than a given threshold is reached. The threshold is specified by bits 6 and 5 of byte 3 as follows&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot; style=&quot;margin-left: auto; margin-right: auto; width: 70%;&quot;&gt;
&lt;table style=&quot;width: 100%;&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Search mode stop levels&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;Bit 6&lt;/th&gt;&lt;th&gt;Bit 5&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;Invalid.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;(low) ADC output level=5.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;(medium) ADC output level=7.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;(high) ADC output level=10.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;pll-register&quot;&gt;The PLL register&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The PLL register is a 14 bits register which is used to set the frequency of the PLL
of TEA5767. The desired frequency is expressed in MHz and it is a float number F&lt;sub&gt;des&lt;/sub&gt; (ranging between 76.0 and 108.0). The formulas for converting this number into an integer to feed the
PLL register depends on: the clock reference frequency (F&lt;sub&gt;REF&lt;/sub&gt;), the intermediate frequency (F&lt;sub&gt;IF&lt;/sub&gt;) and the type of side injection (high or low, see &lt;a href=&quot;https://www.blogger.com/side-injection&quot;&gt;here&lt;/a&gt; for more about side injection).&lt;br /&gt;
The formula when high side injection is chosen is as follows:
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Ou5OANM2MwAnl0SHl6L5A8daSZP3Q_Q3qToFhJd2kiRorPTLjF8p1_pqxv80L7DONqZpGwuQsmgcA0M5nOrSDDgrJ2ZVtmCDtz_Afe5obmLLt-MTzF436xQGEEZogrwvOL2jjCakmVs/s1600/formula-high-side-injection.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Ou5OANM2MwAnl0SHl6L5A8daSZP3Q_Q3qToFhJd2kiRorPTLjF8p1_pqxv80L7DONqZpGwuQsmgcA0M5nOrSDDgrJ2ZVtmCDtz_Afe5obmLLt-MTzF436xQGEEZogrwvOL2jjCakmVs/s1600/formula-high-side-injection.png&quot; height=&quot;60&quot; width=&quot;200&quot;&gt;&lt;/a&gt;&lt;/div&gt;
Remark that when the clock is 32.768KHz then F&lt;sub&gt;REF&lt;/sub&gt; is 32.768KHz (it is 50KHz when the clock is 13MHz or 6.5MHz). Moreover F&lt;sub&gt;IF&lt;/sub&gt; is fixed at 225KHz. Hence our previous formula simplifies as follows&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE9tpsnyfOV6NWlyIhSvik3j01jTDrM3gAUq50gsAJXMFnN75Y6ytOp2BhxFub8FFdWB4iHLJBF-7_cJk95aVt8gkKD9jQFerycYfhvyr2TeHHR5mE7bc4BCyvveSCWTfs41WhvHkPkHA/s1600/formula-high-side-injection-spec.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE9tpsnyfOV6NWlyIhSvik3j01jTDrM3gAUq50gsAJXMFnN75Y6ytOp2BhxFub8FFdWB4iHLJBF-7_cJk95aVt8gkKD9jQFerycYfhvyr2TeHHR5mE7bc4BCyvveSCWTfs41WhvHkPkHA/s1600/formula-high-side-injection-spec.png&quot; height=&quot;48&quot; width=&quot;320&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In the case of low side injection, the previous formulas are changed as follows&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8G18OBBi1RBtjPrCdwE_W9mLv0Ps-y1c9UCeOwI4F8-sGMhxj02BeLNRdCJt-1YY4UdzBnEIddivm7fm6WIloVIy16v-Goe3wzABvHuu_KWLc_zX-hV2FjOsrma9fIrC0-vsHp3yM4co/s1600/formula-low-side-injection.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8G18OBBi1RBtjPrCdwE_W9mLv0Ps-y1c9UCeOwI4F8-sGMhxj02BeLNRdCJt-1YY4UdzBnEIddivm7fm6WIloVIy16v-Goe3wzABvHuu_KWLc_zX-hV2FjOsrma9fIrC0-vsHp3yM4co/s1600/formula-low-side-injection.png&quot; height=&quot;50&quot; width=&quot;200&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
and&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkWbEvzKGrc6T0UhoaeugkSRmF-7qhoZvobSF95ES0AHS6-UcJ_jTDGYUlY-bCKFWpCKeSTBZ9m33Slovs3OLZbGp0MkB6-bDkc4GIyXFsElCM6_wBnLeBwfJL-DJ6jQZw78Ud2IU9cNQ/s1600/formula-low-side-injection-spec.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkWbEvzKGrc6T0UhoaeugkSRmF-7qhoZvobSF95ES0AHS6-UcJ_jTDGYUlY-bCKFWpCKeSTBZ9m33Slovs3OLZbGp0MkB6-bDkc4GIyXFsElCM6_wBnLeBwfJL-DJ6jQZw78Ud2IU9cNQ/s1600/formula-low-side-injection-spec.png&quot; height=&quot;43&quot; width=&quot;320&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;Warning&lt;/span&gt;: in the formula integer division is used! Hence, for example, 5/3=1 and 11/3=3.&lt;/div&gt;
&lt;br /&gt;
The effect of setting the PLL register (and performing a &lt;span style=&quot;font-family: monospace;&quot;&gt;write&lt;/span&gt; operation immediately afterwards) is to tune the FM receiver on F&lt;sub&gt;des&lt;/sub&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;side-injection&quot;&gt;Side injection&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The frequency of the local oscillator f&lt;sub&gt;LO&lt;/sub&gt; is set so the desired reception radio frequency f&lt;sub&gt;RF&lt;/sub&gt; mixes to f&lt;sub&gt;IF&lt;/sub&gt;. There are two choices for the local oscillator frequency because the dominant mixer products are at f&lt;sub&gt;RF&lt;/sub&gt; ± f&lt;sub&gt;LO&lt;/sub&gt;. If the local oscillator frequency is less than the desired reception frequency, it is called low-side injection (f&lt;sub&gt;IF&lt;/sub&gt; = f&lt;sub&gt;RF&lt;/sub&gt; - f&lt;sub&gt;LO&lt;/sub&gt;); if the local oscillator is higher, then it is called high-side injection (f&lt;sub&gt;IF&lt;/sub&gt; = f&lt;sub&gt;LO&lt;/sub&gt; - f&lt;sub&gt;RF&lt;/sub&gt;).&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;soft-ports&quot;&gt;Software ports&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The TEA5757 has two software programmable ports (with open collector). If SWP1 is set then
the soft port 1 operates as a tuning indicator output. As long as the IC has not completed a tuning action, pin SWP1 remains LOW. The pin becomes HIGH, when a preset or search tuning is completed or when a band limit is reached.&lt;br /&gt;
However, remark that this feature cannot be exploited by our module. So the information for
the tuning action complete has to be extracted using the corresponding RF flag in byte 1 of
the reading sequence.&lt;br /&gt;
I&#39;ve not understood what is the purpose of software port 2. Sorry!
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;band-limits&quot;&gt;Band limits&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The module supports two bands:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Japanese (76MHz - 91MHz)&lt;/li&gt;
&lt;li&gt;European/American (87.5MHz - 108MHz)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;
&lt;a href=&quot;https://www.blogger.com/null&quot; name=&quot;clock-frequency&quot;&gt;Clock frequency&lt;/a&gt;&lt;/h4&gt;
The FM receiver can work at three different clock speeds. These can be specified using
Bit PLLREF of Byte 5 and Bit XTAL of Byte 4. Remark that our module has an external
crystal clocked at 32.768 KHz.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;datagrid&quot; style=&quot;margin-left: auto; margin-right: auto; width: 70%;&quot;&gt;
&lt;table style=&quot;width: 100%;&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th colspan=&quot;3&quot; style=&quot;text-align: center;&quot;&gt;Clock frequency setting&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th width=&quot;50&quot;&gt;PLLREF&lt;/th&gt;&lt;th&gt;XTAL&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;13 MHz&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;32.768 kHz&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;6.5 MHz&lt;/td&gt;&lt;/tr&gt;
&lt;tr class=&quot;alt&quot;&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Not allowed.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 id=&quot;soft-mute&quot;&gt;Soft Mute&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The “soft-mute” function suppresses the inter-station noise and prevents excessive noise from being heard when the signal level drops to a low level.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;high-control-cut&quot;&gt;High control cut&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
HCC is a reduction of higher audio frequencies.
The most annoying audio distortions are in the higher
frequency band, so a low pass filter is activated which
reduces the higher frequencies. 
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;stereo-noise-cancelling&quot;&gt;Stereo noise cancelling&lt;/h4&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Stereo Noise Cancelling -also named SDS (Signal dependant stereo)- consists in switching 
the stereo decoder from stereo to mono in case a weak signal is received. This will limit 
the output noise of the decoder. Also by the absence of the pilot or when the stereo control is switched to “force mono”, switching SNC on or off will not affect the audio reception so that only mono information will be passed to the audio output.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;de-emphasis-time-constant&quot;&gt;De-emphasis Time Constant&lt;/h4&gt;
(This section is taken from Wikipedia)&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Random noise has a triangular spectral distribution in an FM system, with the effect that noise occurs predominantly at the highest frequencies within the baseband. This can be offset, to a limited extent, by boosting the high frequencies before transmission and reducing them by a corresponding amount in the receiver. Reducing the high frequencies in the receiver also reduces the high-frequency noise. These processes of boosting and then reducing certain frequencies are known as pre-emphasis and de-emphasis, respectively.

The amount of pre-emphasis and de-emphasis used is defined by the time constant of a simple RC filter circuit. In most of the world a 50 µs time constant is used. In the Americas and South Korea, 75 µs is used. This applies to both mono and stereo transmissions. For stereo, pre-emphasis is applied to the left and right channels before multiplexing.

The amount of pre-emphasis that can be applied is limited by the fact that many forms of contemporary music contain more high-frequency energy than the musical styles which prevailed at the birth of FM broadcasting. They cannot be pre-emphasized as much because it would cause excessive deviation of the FM carrier.
&lt;/div&gt;
&lt;br /&gt;
&lt;h4 id=&quot;alternate&quot;&gt;Alternate modules&lt;/h4&gt;
Many similar modules can be found on the market. You can find below the photos of some which work similarly to the one used for our experiments.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQMkPrSddAcz1Gg5bkUpghN0rW28XUoWfJ8l_uB5fX6m3cnTN0G5zX1KBS4Bi3USWo451WeNSMwabvkuJnencvGCcIx2wIfjcgQyvnYq5QuFvOW9Oc3UqQmzrtnXkN-ccfBeOjdK3AOQo/s1600/FM-receiver-alt3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQMkPrSddAcz1Gg5bkUpghN0rW28XUoWfJ8l_uB5fX6m3cnTN0G5zX1KBS4Bi3USWo451WeNSMwabvkuJnencvGCcIx2wIfjcgQyvnYq5QuFvOW9Oc3UqQmzrtnXkN-ccfBeOjdK3AOQo/s1600/FM-receiver-alt3.jpg&quot; height=&quot;74&quot; width=&quot;200&quot;&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk4yC2A2vS1UjP5URvk9K9y9lmZ4rjYF-ebbUBron_rm2EbcFxrAz__NFv5f-5YfsVpUwejjNoEfB5Fos_kJEI_rg6cc0Vp03sByDiK4IL68jnlwg7wuOKwhArzGyWxJTVSwh34ZWiBI8/s1600/FM-receiver-alt4.png&quot;&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; colspan=&quot;2&quot; style=&quot;text-align: center;&quot;&gt;Figure 3. An example of alternate FM Stereo modules.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h4&gt;What&#39;s next&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
As promised at the very beginning, we are going to provide a complete library for programming
the TEA5767/TEA5768 assorted with an application example. So stay tuned!
&lt;/div&gt;
&lt;br/&gt;
&lt;h4&gt;See also&lt;/h4&gt;
&lt;div style=&quot;text-align:justify&quot;&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/TEA5667-TEA5768-TEA576X-soft.html&quot;&gt;FM radio receiver for your Arduino (TEA5767/TEA5768/TEA5757) (Part 2/4)&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/01/TEA5767-TEA5768-FM-Module.html&quot;&gt;FM Radio receiver (TEA5767HL-TEA5767HN-TEA5768HL) (Part 3/4)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2015/02/fm-radio-frontend.html&quot;&gt;FM Radio receiver (TEA5767HL-TEA5767HN-TEA5768HL) (Part 4/4)&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;</description><link>https://macduino.blogspot.com/2014/12/FM-Radio-TEA5767.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjimagfNTuxSFlJT7om9O7TdRc-4-71T0q1FIdIC_ed78ZRFpgk1bCtu90RuAgpVB5vvwd98zHmq2mhJC6a-TASJOWjC7rdHuOdSdc4vySaa1petY1t8-ts5OHZ0nzhdzijSUHT1JbXbQA/s72-c/FM-Stereo-Module.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-6666994613446189532</guid><pubDate>Sun, 14 Dec 2014 20:46:00 +0000</pubDate><atom:updated>2014-12-25T08:20:30.501+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">arduino music</category><category domain="http://www.blogger.com/atom/ns#">arduino sound</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">buzzer</category><category domain="http://www.blogger.com/atom/ns#">buzzer music</category><category domain="http://www.blogger.com/atom/ns#">Lost treasures</category><category domain="http://www.blogger.com/atom/ns#">loudspeaker</category><category domain="http://www.blogger.com/atom/ns#">music</category><category domain="http://www.blogger.com/atom/ns#">Other</category><category domain="http://www.blogger.com/atom/ns#">tone music</category><title>Tone music surprises</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var myLabels = new Array(&quot;Other&quot;,&quot;Lost treasures&quot;);
&lt;/script&gt;

&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVbLNiJevFuuTZ_D2qhg7yeZGVzdSKn247xm5T1-yOSbS7sO5l9cJaD9a5jb_dEv1ICnlppa-IxqsB3x3DzcFtYlbRZX6F43Xqq9bi32rJxjOek5WolmIxFRGde5LSlz_Q8mLT5CHaftQ/s1600/sheet-music-small.jpg&quot; style=&quot;border-radius: 8px;&quot; /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;border-radius: 8px; clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
Hey all! It&#39;s almost Christmas and time for the traditional carols. I&#39;ve found a 8Ω loudspeaker from an old PC and I went through a classic Arduino Sketch for beginners. I&#39;ve optimized it a little bit. Moreover, I&#39;ve translated into French/Italian the notes and
introduced standardized length for durations and the possibility to add pauses.
&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;The carols&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
And here are some carols that I&#39;ve just encoded.
&lt;/div&gt;
&lt;hr /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;float: left; padding-bottom: 8px; padding-left: 10px; padding-right: 8px; padding-top: 2px;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk4S793oPPWdnGEQ2YdOFQNzlinrn-6IjTQvg8jjfCNfsz1qA4BusW2tvOcXX-XlXe0RXTxVfs5-WSyAjw-9QAa-D-wsstWABe8MpYgSCEC6DbhA_jGT8nO3fDY97457a2V7zz0Yg_7_M/s1600/Franz_Xaver_Gruber_icon.jpg&quot; /&gt;&lt;/div&gt;
&lt;b&gt;Silent Night&lt;/b&gt;&lt;br /&gt;
(German: Stille Nacht, French: Douce Nuit, Italian: Astro del ciel)
&lt;br /&gt;
&lt;br /&gt;
Popular Christmas carol, composed in 1818 by Franz Xaver Gruber to lyrics by Joseph Mohr.
It was declared an intangible cultural heritage by UNESCO in March 2011.
&lt;br /&gt;
&lt;div style=&quot;line-height: 2em;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Download this tone music for Arduino &lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_LXAwYktwVThaVVU&amp;amp;authuser=0&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
&lt;hr /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;float: left; padding-bottom: 8px; padding-left: 10px; padding-right: 8px; padding-top: 2px;&quot;&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfXYGWUyQHzWVohqZWUHz8uO_P2PpuVB8ufYFhPV_ZvnPnJdZhemCzJwl6ahevGMTcjyR5zX5fLCj57Rgh-d7_Td7GEdp-G5h4v4KJ7CJvff575GtlqRQ1kXt5RU4P4HdXyAKX0oumWYs/s1600/One_Horse_Open_Sleigh_title_page_icon.jpg&quot; /&gt;&lt;/div&gt;
&lt;b&gt;Jingle Bells&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This is one of the most known Christmas carols. It was written by James Lord Pierpont (1822–1893) and published under the title &quot;One Horse Open Sleigh&quot; in the autumn of 1857.&lt;br /&gt;
&lt;br /&gt;
Download this tone music for Arduino &lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_Z2ZyaEFRQnFUQk0&amp;amp;authuser=0&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;float: left; padding-bottom: 8px; padding-left: 10px; padding-right: 8px; padding-top: 2px;&quot;&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN85KmJFVfCpUCxO6UlEl2R728yvF_Vj1EsXO4kb9gYD1ZG5iEJGeQY2gK0iEVfjZu8_BOPI0gwNkhvo5IbchMyKJQgvsyk7UFDKRCHhn5_Z440JReZXSugbkEHhqi8m_hmQ9Fi7eqO5Q/s1600/Hark_Herald_Angels_Sing_icon.jpg&quot; /&gt;
&lt;/div&gt;
&lt;b&gt;Hark! The herald-angels sing&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Another very popular carol  first appeared in 1739 in the collection &quot;Hymns and Sacred Poems&quot; by Charles Wesley. Successively, it has been adapted by many musicians among which we also
find Felix Mendelssohn and William H. Cummings.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;padding-left: 118px;&quot;&gt;
Download this tone music for Arduino &lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_WlZIcktJaHRSQ0E&amp;amp;authuser=0&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;b&gt;The sketch&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In order to run the sketch for playing tone music with your Arduino, you need to download the following header files:&amp;nbsp;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_M2hGdEczQTdZaDg&amp;amp;authuser=0&quot;&gt;pitches.h&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;https://drive.google.com/open?id=0B9uM_EGS3kp_ZXdvNE5YWF9jN2c&amp;amp;authuser=0&quot;&gt;durations.h&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: .1em .1em .1em .1em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;/*&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  Adapted by Enrico Formenti&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  from an original sketch by Tom Igoe&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  &lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  BSD license, check license.txt for more information&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  All text above must be included in any redistribution.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; *  See macduino.blogspot.com for more details.&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt; */&lt;/span&gt;

&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;pitches.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;durations.h&quot;&lt;/span&gt;
&lt;span style=&quot;color: #557799;&quot;&gt;#include &quot;SilentNight.h&quot;&lt;/span&gt;
 
&lt;span style=&quot;color: #557799;&quot;&gt;#define TONEPIN 8&lt;/span&gt;

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;setup&lt;/span&gt;() {
  
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; curNote &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;; curNote &lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt; melody_len; curNote&lt;span style=&quot;color: #333333;&quot;&gt;++&lt;/span&gt;) {

    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;(melody[curNote])
      tone(TONEPIN, melody[curNote],noteDurations[curNote]);
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; {
      noTone(TONEPIN);
      delay(noteDurations[curNote]);
    }

    &lt;span style=&quot;color: #888888;&quot;&gt;// to distinguish the notes, set a minimum time between them.&lt;/span&gt;
    &lt;span style=&quot;color: #888888;&quot;&gt;// the note&#39;s duration + 30% seems to work well:&lt;/span&gt;
    delay(noteDurations[curNote] &lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #6600ee; font-weight: bold;&quot;&gt;1.3&lt;/span&gt;);
    &lt;span style=&quot;color: #888888;&quot;&gt;// stop the tone playing:&lt;/span&gt;
    noTone(TONEPIN);
  }
}

&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;loop&lt;/span&gt;() {
  &lt;span style=&quot;color: #888888;&quot;&gt;// no need to repeat the melody.&lt;/span&gt;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;The circuit&lt;/b&gt;&lt;br /&gt;
It is a real Arduino&#39;s classic. You need:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;1KΩ resistor 1/4W&lt;/li&gt;
&lt;li&gt;8Ω 1/4W loudspeaker&lt;/li&gt;
&lt;li&gt;your Arduino and 3 cables&lt;/li&gt;
&lt;/ul&gt;
Here is the &lt;a href=&quot;http://www.fritzing.org/&quot; target=&quot;_blank&quot;&gt;Fritzing&lt;/a&gt; scheme for the circuit&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaD37cL2ByrvjomefCA7Bgox_eBxLLMhQMx8gxeTwNt3fE3YKqyuGJtel1LJk9bCAtpmIqn7SuhqPRC7TkqR1V_iIx0d-hJoIeNu8ks3_cNT21CwSTvX738vVvucbHXAnKOdvrdFUXLJE/s1600/Loudspeaker_sketch_small.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaD37cL2ByrvjomefCA7Bgox_eBxLLMhQMx8gxeTwNt3fE3YKqyuGJtel1LJk9bCAtpmIqn7SuhqPRC7TkqR1V_iIx0d-hJoIeNu8ks3_cNT21CwSTvX738vVvucbHXAnKOdvrdFUXLJE/s1600/Loudspeaker_sketch_small.jpg&quot; height=&quot;177&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What&#39;s next&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Indeed, I&#39;m translating lots of tone music of various genres. So expect a post with lots of new music tones! In the meanwhile, you can send me your own, I will publish and credit all of them!&lt;/div&gt;
&lt;br/&gt;
&lt;b&gt;See also&lt;/b&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-advanced-playing-software.html&quot;&gt;
Tone music: advanced playing software&lt;/a&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-encoding-howto.html&quot;&gt;Tone music: how to encode melodies&lt;/a&gt;
&lt;br/&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/12/tone-music-changing-tempo.html&quot;&gt;Tone music: changing the Tempo of your melodies&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Credits&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The image opening this post comes from &lt;a href=&quot;http://amagico.com/&quot;&gt;Amagico.com&lt;/a&gt; website and according to them it is believed to be in the public domain. The icons illustrating the three tone musics come from &lt;a href=&quot;http://wikipedia.com/&quot;&gt;Wikipedia.com&lt;/a&gt;&lt;/div&gt;</description><link>https://macduino.blogspot.com/2014/12/tone-music-surprises.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVbLNiJevFuuTZ_D2qhg7yeZGVzdSKn247xm5T1-yOSbS7sO5l9cJaD9a5jb_dEv1ICnlppa-IxqsB3x3DzcFtYlbRZX6F43Xqq9bi32rJxjOek5WolmIxFRGde5LSlz_Q8mLT5CHaftQ/s72-c/sheet-music-small.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-272410251837266351</guid><pubDate>Fri, 05 Dec 2014 19:44:00 +0000</pubDate><atom:updated>2014-12-07T23:32:20.677+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino 2</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">LCD driving</category><category domain="http://www.blogger.com/atom/ns#">LCD static drive</category><category domain="http://www.blogger.com/atom/ns#">Theory</category><title>LCD : static driving</title><description>&lt;script type=&quot;text/javascript&quot;&gt;
var myLabels = new Array(&quot;Theory&quot;,&quot;LCD&quot;);
&lt;/script&gt;

&lt;b&gt;Abstract&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The static driving technique is the basic driving of a LCD which has the advantage of needing fewer external support but needs lots of pins for the segments of the LCD and hence allows less dense design.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;The idea&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
For each digit, each segment is directly connected to a pin. In order to save some pins, all the other electrodes of each segment is linked together into a common pin.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The example&lt;/b&gt;&lt;br /&gt;
Consider an LCD with two digits. It is composed of a front plane and a back plane. In the front pane, each segment of a digit is connected to a distinct pin as illustrated in Figure 1, remark the density of connections. In the back pane all the electrodes of all the digits are connected each other and finally to a common (&lt;i&gt;com&lt;/i&gt;) pin as illustrated in Figure 2. Therefore, if we count pins, there are 8 pins per digit in the front pane, plus one pin for the back plane. Summing up with a formula, the number of pins is 8N+1, where N is the number of digits in the display.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTzYKXDtpB-gZXF2MlvMi5z6pvHt1E6gqmAaIbrWSgFRm_lD2I56wqajR9wVOSCuESB-guT2LRrf2BHr-7tMTaC7pKVP-XfrqFjtZslWcEv6vj8hHnxFtfgMVaMoIhZTr5q_y7NutR2I/s1600/LCD-static-drive-frontpane.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTzYKXDtpB-gZXF2MlvMi5z6pvHt1E6gqmAaIbrWSgFRm_lD2I56wqajR9wVOSCuESB-guT2LRrf2BHr-7tMTaC7pKVP-XfrqFjtZslWcEv6vj8hHnxFtfgMVaMoIhZTr5q_y7NutR2I/s1600/LCD-static-drive-frontpane.png&quot; height=&quot;221&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 1. Front pane for two-digits LCD with static driving.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMaTzQSblkV3zlMsoMknSBnt9Bbz3qIkI2aXkNlUrpaciBcgIumnycvghyHzWMRSvurbHV0FM0_n5bcQx1CjED-OsAmZ51orC9PCDQPIeRlGIrAuQwCG1dqMpXxGqnxknNZaJeQ0qnMUY/s1600/LCD-static-drive-backpane.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMaTzQSblkV3zlMsoMknSBnt9Bbz3qIkI2aXkNlUrpaciBcgIumnycvghyHzWMRSvurbHV0FM0_n5bcQx1CjED-OsAmZ51orC9PCDQPIeRlGIrAuQwCG1dqMpXxGqnxknNZaJeQ0qnMUY/s1600/LCD-static-drive-backpane.png&quot; height=&quot;210&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 2. Back pane for two-digits LCD with static driving.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Frame frequency and bias&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
LCD are AC devices and hence one must specify the AC frequency used. Frame frequency ranges between 20Hz and 200Hz. Below 20Hz, one might experience the refreshes of the LCD (recall that human eye can distinguish frames up to 18 frames/second). A frequency higher than 200Hz might cause problems with the capacitive elements of the LCD.&lt;br /&gt;
&lt;br /&gt;
The bias is the number of voltage levels that are used. Indeed, in static driving only two levels are used, say V&lt;sub&gt;0&lt;/sub&gt; and V&lt;sub&gt;1&lt;/sub&gt;. As an example, consider a given segment SEG. In oder to deduce the waveforms passing through the backpane COM and SEG, let us impose that V&lt;sub&gt;COM&amp;nbsp;&lt;/sub&gt;- V&lt;sub&gt;SEG&amp;nbsp;&lt;/sub&gt;= 0 whenever SEG is unselected (see Figure 3). Since we should switch of value during the frame and there are only two possible values, then the waveform of SEG signal when SEG is selected, it is the complement of the signal unselected signal. As a consequence, when SEG is selected, the COM-SEG signal has a peak-to-peak amplitude equal to 2V&lt;sub&gt;1&lt;/sub&gt;. See Figure 4.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju25NZrH9vLxv4Q_0SLH1YC4zspp8DaKkQ3V3Zh1C2hx8gCVnhJURwP_ifQGiaRlC7Ecd8qoEdUwy65eoemUrA6bCnzlGPECgIdudAmD4oq4A3d2lR4UE3DV9vVVDHJdv9pDU-WYe_w2A/s1600/static-drive-bias-seg-unselected.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju25NZrH9vLxv4Q_0SLH1YC4zspp8DaKkQ3V3Zh1C2hx8gCVnhJURwP_ifQGiaRlC7Ecd8qoEdUwy65eoemUrA6bCnzlGPECgIdudAmD4oq4A3d2lR4UE3DV9vVVDHJdv9pDU-WYe_w2A/s1600/static-drive-bias-seg-unselected.png&quot; height=&quot;276&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 3. Waveforms when SEG is unselected.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB5e4F41FKSJHpUe6pJF1MAVVBczGgSR4F__qc2CRXqEA0S9lLJJo8gcvav6hZIkRcDmj_K2LoturPMOmfmXlXPvDBmCMi28yPHf1bWyS0wJS_htWOzMolZOZcpdJqbkbMh8JsTgNwe-0/s1600/static-drive-bias-seg-selected.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB5e4F41FKSJHpUe6pJF1MAVVBczGgSR4F__qc2CRXqEA0S9lLJJo8gcvav6hZIkRcDmj_K2LoturPMOmfmXlXPvDBmCMi28yPHf1bWyS0wJS_htWOzMolZOZcpdJqbkbMh8JsTgNwe-0/s1600/static-drive-bias-seg-selected.png&quot; height=&quot;292&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Figure 4. Waveforms when SEG is selected.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;See also&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://macduino.blogspot.com/2014/02/LCD-multiplexing-technique.html&quot;&gt;LCD : the multiplexing technique&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
</description><link>https://macduino.blogspot.com/2014/12/LCD-static-driving.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTzYKXDtpB-gZXF2MlvMi5z6pvHt1E6gqmAaIbrWSgFRm_lD2I56wqajR9wVOSCuESB-guT2LRrf2BHr-7tMTaC7pKVP-XfrqFjtZslWcEv6vj8hHnxFtfgMVaMoIhZTr5q_y7NutR2I/s72-c/LCD-static-drive-frontpane.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5076928765077392764.post-3461540978337557619</guid><pubDate>Sat, 15 Feb 2014 15:54:00 +0000</pubDate><atom:updated>2014-12-05T21:31:42.609+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Arduino</category><category domain="http://www.blogger.com/atom/ns#">Arduino 2</category><category domain="http://www.blogger.com/atom/ns#">Arduino Due</category><category domain="http://www.blogger.com/atom/ns#">Arduino Leonardo</category><category domain="http://www.blogger.com/atom/ns#">Arduino Mega</category><category domain="http://www.blogger.com/atom/ns#">Arduino Uno</category><category domain="http://www.blogger.com/atom/ns#">LCD multiplexing</category><category domain="http://www.blogger.com/atom/ns#">Theory</category><title>LCD: the multiplexing technique</title><description>&lt;script type=&quot;text/javascript&quot;&gt;
var myLabels = new Array(&quot;Theory&quot;,&quot;LCD&quot;);
&lt;/script&gt;

&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;Abstract&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;The multiplexing technique for LCD aims at reducing the number of pins that are necessary for driving segments of the display. This results in a simplified LCD design.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;The principle&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;The basic idea is to group segments connections &lt;i&gt;backplanes&lt;/i&gt; or &lt;i&gt;segment commons&lt;/i&gt;. A group is affected to a unique backplane. Therefore, to address a given segment it is enough to ‘access’ to the given group and then specify which element of the group is desired.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;The example&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;Consider a seven segments LCD (with decimal dot) and assume that it has 4 backplanes, named &lt;i&gt;com1&lt;/i&gt;, &lt;i&gt;com2&lt;/i&gt;, &lt;i&gt;com3&lt;/i&gt;, &lt;i&gt;com4&lt;/i&gt;. Then, the segments of a given digit can be grouped by 2 as follows: &lt;i&gt;ah&lt;/i&gt; (com1), &lt;i&gt;bg&lt;/i&gt; (com2), &lt;i&gt;fe&lt;/i&gt; (com3), &lt;i&gt;cd&lt;/i&gt; (com4). The following figure illustrates the wiring of the segments of a multiple digits display.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIQcioln3ZWPamWDckIdeo0XMpUOE_FMklHf64SlQXI6l4yOEWQyXxs4QFWtCgpQvvkI0fvAzdP6M91Po_KhDt2sgEdDXKjnNZzoN-WR6vBYRk_W-1OdlDSvR8vXT_VnRpLsd5UOAkfc8/s1600/7seg-backplanes-connections.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIQcioln3ZWPamWDckIdeo0XMpUOE_FMklHf64SlQXI6l4yOEWQyXxs4QFWtCgpQvvkI0fvAzdP6M91Po_KhDt2sgEdDXKjnNZzoN-WR6vBYRk_W-1OdlDSvR8vXT_VnRpLsd5UOAkfc8/s1600/7seg-backplanes-connections.png&quot; height=&quot;298&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Wiring of the segments in the backplanes for a multiplexed LCD.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;Moreover, the segments on the front conductive plane are grouped by 4: abfc and hged as pictured in the following figure.&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizPDK1b-j9jQhUYQwY1_Ewa7CY8vn6G-W97VWqxiDrjeuqGMc84VCfFr2nZtXccF3eRwBMZayc29ADqSIKsxDuV4Cfh_OmpwSdeH68kuhJvCFDrad_4TYA0XB0z2CgqQmXEFfDIQ2vOVs/s1600/7seg-front-plane-connections.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizPDK1b-j9jQhUYQwY1_Ewa7CY8vn6G-W97VWqxiDrjeuqGMc84VCfFr2nZtXccF3eRwBMZayc29ADqSIKsxDuV4Cfh_OmpwSdeH68kuhJvCFDrad_4TYA0XB0z2CgqQmXEFfDIQ2vOVs/s1600/7seg-front-plane-connections.png&quot; height=&quot;348&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Wiring of the frontplane in a multiplexed LCD.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;b&gt;What we gain&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;The attentive reader should already have remarked that these groups are not chosen randomly. Indeed, groups in the front plane are chosen so elements belonging to a group belongs to distinct backplanes. In this way, specifying a group and a backplane we uniquely address a segment. Moreover, remark that backplanes are common to all digits in the display. In this way if N is the number of digits in the display, one need only 2N+4 pins &lt;/span&gt;&lt;span style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;instead of 8N+1 as in static driving technique (to be seen in a next post).&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b style=&quot;font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;What we loose&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;This great simplification in display design has not only advantages. Indeed, recall that each LCD must be driven by an alternated current. Multiplexing the backplanes makes more complex the AC driving section of the module. This will be explained in a next post.&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;&lt;b&gt;What&#39;s next&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;
&lt;/span&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;- &lt;a href=&quot;http://macduino.blogspot.com/2014/12/LCD-static-driving.html&quot;&gt;LCD: static driving&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
- LCD: multiplexing and bias&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Enjoy!&lt;/b&gt;&lt;/div&gt;
&lt;/span&gt;</description><link>https://macduino.blogspot.com/2014/02/LCD-multiplexing-technique.html</link><author>noreply@blogger.com (Maczinga)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIQcioln3ZWPamWDckIdeo0XMpUOE_FMklHf64SlQXI6l4yOEWQyXxs4QFWtCgpQvvkI0fvAzdP6M91Po_KhDt2sgEdDXKjnNZzoN-WR6vBYRk_W-1OdlDSvR8vXT_VnRpLsd5UOAkfc8/s72-c/7seg-backplanes-connections.png" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>