<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; Анализатор спектра LCD2004]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=104&amp;type=atom" />
	<updated>2023-05-30T11:21:36Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=104</id>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=7871#p7871" />
			<content type="html"><![CDATA[<p>Всем Доброго! Поднимаю тему. Заказал на Али с серым экраном LCD2004. Гораздо эффектнее смотрится. Надоели уже эти синие и желтые экраны. Подключение LCD паралельное. Параметр (А0) умножил на 10. Все отлично скачет и прыгает при&nbsp; уровне в 0дб. Прокатал на генераторе. Все ровненько поднимается вплоть до 8 кгц. А дальше уже и не нужно особо, только занимать правые полосы для отображения ВЧ, которые, дай бог ,пару раз прыгнут в течении одной песни, а то и вообще не поднимутся.<br />Итого: конструкция рабочая и поддающаяся настройке - я доволен.</p>]]></content>
			<author>
				<name><![CDATA[3484480]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2100</uri>
			</author>
			<updated>2023-05-30T11:21:36Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=7871#p7871</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6525#p6525" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>karvik7777 пишет:</cite><blockquote><div class="quotebox"><cite>liman324 пишет:</cite><blockquote><p>LiquidCrystal lcd(6, 7, 8, 9, 10, 11); </p><p>ARDUINO LCD<br />D6 =&nbsp; &nbsp; &nbsp; &nbsp;RS<br />D7 =&nbsp; &nbsp; &nbsp; &nbsp;E<br />D8 =&nbsp; &nbsp; &nbsp; &nbsp;D4<br />D9 =&nbsp; &nbsp; &nbsp; &nbsp;D5<br />D10 =&nbsp; &nbsp; &nbsp;D6<br />D11 =&nbsp; &nbsp; &nbsp;D7<br />GND&nbsp; =&nbsp; &nbsp;RW<br />GND =&nbsp; &nbsp; VSS<br />+5V =&nbsp; &nbsp; VDD</p></blockquote></div><p>Спасибо Вам огромное. Переменный резистор для контраста подключать по такой схеме, как в статье, что вы мне скинули?</p></blockquote></div><p>Ура! Заработало! Спасибо большое.</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T14:52:48Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6525#p6525</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6524#p6524" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>liman324 пишет:</cite><blockquote><div class="quotebox"><blockquote><p>Переменный резистор для контраста подключать по такой схеме, как в статье, что вы мне скинули?</p></blockquote></div><p>да</p></blockquote></div><p>Спасибо большое!</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T14:30:08Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6524#p6524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6523#p6523" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Переменный резистор для контраста подключать по такой схеме, как в статье, что вы мне скинули?</p></blockquote></div><p>да</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-08-08T14:29:13Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6523#p6523</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6522#p6522" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>liman324 пишет:</cite><blockquote><p>LiquidCrystal lcd(6, 7, 8, 9, 10, 11); </p><p>ARDUINO LCD<br />D6 =&nbsp; &nbsp; &nbsp; &nbsp;RS<br />D7 =&nbsp; &nbsp; &nbsp; &nbsp;E<br />D8 =&nbsp; &nbsp; &nbsp; &nbsp;D4<br />D9 =&nbsp; &nbsp; &nbsp; &nbsp;D5<br />D10 =&nbsp; &nbsp; &nbsp;D6<br />D11 =&nbsp; &nbsp; &nbsp;D7<br />GND&nbsp; =&nbsp; &nbsp;RW<br />GND =&nbsp; &nbsp; VSS<br />+5V =&nbsp; &nbsp; VDD</p></blockquote></div><p>Спасибо Вам огромное. Переменный резистор для контраста подключать по такой схеме, как в статье, что вы мне скинули?</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T14:28:04Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6522#p6522</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6521#p6521" />
			<content type="html"><![CDATA[<p>опубликуйте скетч который Вы используете я его переделаю под параллельное подключение дисплея</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-08-08T14:27:33Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6521#p6521</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6520#p6520" />
			<content type="html"><![CDATA[<p>I2C Не нужно использовать, низкая скорость работы дисплея</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-08-08T14:26:33Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6520#p6520</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6519#p6519" />
			<content type="html"><![CDATA[<p>LiquidCrystal lcd(6, 7, 8, 9, 10, 11); </p><p>ARDUINO LCD<br />D6 =&nbsp; &nbsp; &nbsp; &nbsp;RS<br />D7 =&nbsp; &nbsp; &nbsp; &nbsp;E<br />D8 =&nbsp; &nbsp; &nbsp; &nbsp;D4<br />D9 =&nbsp; &nbsp; &nbsp; &nbsp;D5<br />D10 =&nbsp; &nbsp; &nbsp;D6<br />D11 =&nbsp; &nbsp; &nbsp;D7<br />GND&nbsp; =&nbsp; &nbsp;RW<br />GND =&nbsp; &nbsp; VSS<br />+5V =&nbsp; &nbsp; VDD</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-08-08T14:25:46Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6519#p6519</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6518#p6518" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>liman324 пишет:</cite><blockquote><p>Здравствуйте. Посмотрите статью <a href="http://rcl-radio.ru/?p=42773,">http://rcl-radio.ru/?p=42773,</a> подключение lcd1602 и lcd2004 аналогичны. Единственная разница в</p><p> lcd.begin(16, 2);// указываем тип дисплея LCD 16X2</p><p> lcd.begin(20, 4);// указываем тип дисплея LCD 20X4</p></blockquote></div><p>Собрал подключением по I2C, всё заработало, но не нравится скорость</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T14:23:58Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6518#p6518</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6517#p6517" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>liman324 пишет:</cite><blockquote><p>Здравствуйте. Посмотрите статью <a href="http://rcl-radio.ru/?p=42773,">http://rcl-radio.ru/?p=42773,</a> подключение lcd1602 и lcd2004 аналогичны. Единственная разница в</p><p> lcd.begin(16, 2);// указываем тип дисплея LCD 16X2</p><p> lcd.begin(20, 4);// указываем тип дисплея LCD 20X4</p></blockquote></div><p>Я хотел бы собрать по вашему скетчу, а в вашем скетче строка с пинами LiquidCrystal lcd(6, 7, 8, 9, 10, 11). А в статье, что вы мне скинули, там подключение LiquidCrystal lcd(12, 11, 5, 4, 3, 2). Я новичок в этом деле, только учусь. Извините за глупые вопросы. Подскажите как подключить именно по вашему скетчу, куда какой пин. Заранее спасибо.</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T14:21:58Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6517#p6517</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6516#p6516" />
			<content type="html"><![CDATA[<p>Здравствуйте. Посмотрите статью <a href="http://rcl-radio.ru/?p=42773,">http://rcl-radio.ru/?p=42773,</a> подключение lcd1602 и lcd2004 аналогичны. Единственная разница в</p><p> lcd.begin(16, 2);// указываем тип дисплея LCD 16X2</p><p> lcd.begin(20, 4);// указываем тип дисплея LCD 20X4</p>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-08-08T14:08:50Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6516#p6516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=6515#p6515" />
			<content type="html"><![CDATA[<p>Здравствуйте! Помогите пожалуйста со схемой подключения экрана напрямую к ардуино. Какие куда пины, куда переменный резистор для контраста? Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[karvik7777]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1822</uri>
			</author>
			<updated>2022-08-08T11:22:07Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=6515#p6515</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=4921#p4921" />
			<content type="html"><![CDATA[<p>Попробуйте этот код (вход А0)</p><div class="codebox"><pre><code>#define LOG_OUT 1
#define AUTO_GAIN 1        // автонастройка по громкости
#define LOW_PASS 30        // нижний порог чувствительности шумов (нет скачков при отсутствии звука)
#define DEF_GAIN 120       // максимальный порог по умолчанию 
#define FHT_N 128          // ширина спектра х2
#define LOG_OUT 1

  #include &lt;FHT.h&gt; 
  #include &lt;EEPROM.h&gt;
  #include &lt;Wire.h&gt; 
  #include &lt;LiquidCrystal.h&gt;
  #define PIN_RELAY 2
  #define AUDIO_IN 16

 #define printByte(args) write(args);
   double prevVolts = 100.0;

      LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
      byte posOffset[20] = {2,3,4,6,8,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38};// средний спектр
      byte maxValue, maxValue_f,ww=1,gain_sp = DEF_GAIN;
      float k = 0.1;
      int i1,yyy,spek;
      unsigned long gainTimer;

      
   
void setup(){
    ADMUX  = 0b11000000; ADCSRA = 0b11010110;
/*   
  ADCSRA [2:0] скорость аналогового входа
  000 - CLK/2
  001 - CLK/2
  010 - CLK/4
  011 - CLK/8
  100 - CLK/16
  101 - CLK/32
  110 - CLK/64 &#039;
  111 - CLK/128    
*/
  
   Serial.begin(9600);Wire.begin();lcd.begin(20,4);// LCD 20X4
   pinMode(12,INPUT);

   spek = EEPROM.read(100);
   lcd.print(&quot;MUTED, please wait..  &quot;);delay(200);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(300);

   lcd.clear();
   
   pinMode(PIN_RELAY, OUTPUT); // Объявляем пин реле как выход
  digitalWrite(PIN_RELAY, HIGH); // Выключаем реле - посылаем высокий сигнал
   lcd.print(&quot;                       ON AIR! ENJOY!&quot;);delay(200);
   
  
   
   
}



 void loop(){
   if(digitalRead(12)==HIGH){spek++;EEPROM.update(100,spek); ww=1;if(spek&gt;5){spek=0;}delay(300);}

    
      if(spek==0&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 14};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 14, 14};
      byte v3[8] = {0, 0, 0, 0, 0, 14, 14, 14};
      byte v4[8] = {0, 0, 0, 0, 14, 14, 14, 14};
      byte v5[8] = {0, 0, 0, 14, 14, 14, 14, 14};
      byte v6[8] = {0, 0, 14, 14, 14, 14, 14, 14};
      byte v7[8] = {0, 14, 14, 14, 14, 14, 14, 14};
      byte v8[8] = {14, 14, 14, 14, 14, 14, 14, 14};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

       if(spek==1&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 4};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 4, 4};
      byte v3[8] = {0, 0, 0, 0, 0, 4, 4, 4};
      byte v4[8] = {0, 0, 0, 0, 4, 4, 4, 4};
      byte v5[8] = {0, 0, 0, 4, 4, 4, 4, 4};
      byte v6[8] = {0, 0, 4, 4, 4, 4, 4, 4};
      byte v7[8] = {0, 4, 4, 4, 4, 4, 4, 4};
      byte v8[8] = {4, 4, 4, 4, 4, 4, 4, 4};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}



      if(spek==2&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 10};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 10, 10};
      byte v3[8] = {0, 0, 0, 0, 0, 10, 10, 10};
      byte v4[8] = {0, 0, 0, 0, 10, 10, 10, 10};
      byte v5[8] = {0, 0, 0, 10, 10, 10, 10, 10};
      byte v6[8] = {0, 0, 10, 10, 10, 10, 10, 10};
      byte v7[8] = {0, 10, 10, 10, 10, 10, 10, 10};
      byte v8[8] = {10, 10, 10, 10, 10, 10, 10, 10};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==3&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 27};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 27, 27};
      byte v3[8] = {0, 0, 0, 0, 0, 27, 27, 27};
      byte v4[8] = {0, 0, 0, 0, 27, 27, 27, 27};
      byte v5[8] = {0, 0, 0, 27, 27, 27, 27, 27};
      byte v6[8] = {0, 0, 27, 27, 27, 27, 27, 27};
      byte v7[8] = {0, 27, 27, 27, 27, 27, 27, 27};
      byte v8[8] = {27, 27, 27, 27, 27, 27, 27, 27};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==4&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 31};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 31, 31};
      byte v3[8] = {0, 0, 0, 0, 0, 31, 31, 31};
      byte v4[8] = {0, 0, 0, 0, 31, 31, 31, 31};
      byte v5[8] = {0, 0, 0, 31, 31, 31, 31, 31};
      byte v6[8] = {0, 0, 31, 31, 31, 31, 31, 31};
      byte v7[8] = {0, 31, 31, 31, 31, 31, 31, 31};
      byte v8[8] = {31, 31, 31, 31, 31, 31, 31, 31};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==5&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 21};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 21, 21};
      byte v3[8] = {0, 0, 0, 0, 0, 21, 21, 21};
      byte v4[8] = {0, 0, 0, 0, 21, 21, 21, 21};
      byte v5[8] = {0, 0, 0, 21, 21, 21, 21, 21};
      byte v6[8] = {0, 0, 21, 21, 21, 21, 21, 21};
      byte v7[8] = {0, 21, 21, 21, 21, 21, 21, 21};
      byte v8[8] = {21, 21, 21, 21, 21, 21, 21, 21};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

    
      analyzeAudio();   // функция FHT, забивает массив fht_log_out[] величинами по спектру

      for (int pos = 0; pos &lt; 20; pos++) {  
        if (fht_log_out[posOffset[pos]] &gt; maxValue) maxValue = fht_log_out[posOffset[pos]];
        
        
        
        int posLevel = map(fht_log_out[posOffset[pos]], LOW_PASS, gain_sp, 0, 31);
        posLevel = constrain(posLevel, 0, 31);

   if(posLevel&lt;7){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 1);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 2);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)posLevel);}
   
   if(posLevel&gt;7&amp;&amp;posLevel&lt;15){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 1);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);lcd.setCursor(pos, 2);lcd.write((uint8_t)posLevel-8);}

   if(posLevel&gt;15&amp;&amp;posLevel&lt;23){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 2);lcd.write((uint8_t)7);lcd.setCursor(pos, 1);lcd.write((uint8_t)posLevel-16);}    

   if(posLevel&gt;23&amp;&amp;posLevel&lt;31){
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 2);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 1);lcd.write((uint8_t)7);lcd.setCursor(pos, 0);lcd.write((uint8_t)posLevel-24);}           
      }


   if (AUTO_GAIN) {
    if (millis() - gainTimer &gt; 10) {      
      maxValue_f = maxValue * k + maxValue_f * (1 - k);
      if(maxValue_f &gt; LOW_PASS) gain_sp = maxValue_f;else gain_sp = DEF_GAIN;gainTimer = millis();}} 
  }// loop

void analyzeAudio() { 
 while(i1 &lt; FHT_N){i1++; 
    do{ADCSRA |= (1 &lt;&lt; ADSC);} 
    while((ADCSRA &amp; (1 &lt;&lt; ADIF)) == 0);fht_input[i1] = (ADCL|ADCH &lt;&lt; 8);}i1=0;
    fht_window(); // window the data for better frequency response
    fht_reorder(); // reorder the data before doing the fht
    fht_run(); // process the data in the fht
    fht_mag_log(); // take the output of the fht
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[liman324]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=2</uri>
			</author>
			<updated>2021-12-14T15:17:41Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=4921#p4921</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=4920#p4920" />
			<content type="html"><![CDATA[<p>Если тема еще жива, прошу помощи!</p><p>Автору большое спасибо за проект именно с этим LCD экраном, больше нигде найти не смог, а хотелось чуть больше&nbsp; &nbsp;чем 1602 экран.. </p><p>Собрал все работает, кнопка режимы переключает, сделал задержку на включение усилка, чтоб щелчков при включении не было сделал.. графики пляшут, красиво..</p><p>НО при проверка не генераторе частоты оказалось что пляшут они в совершенно случайном порядке. до 1кГц еще есть какая-то зависимость (несколько полосок вместе двигаются с левого до правого края), но дальше - чистый набор шумов и гармоник на дисплее в случайных местах и случайной высоты!</p><p> Что я уже только не пробовал,&nbsp; и все коды приведенные выше, и входные пины менять и библиотеки переподгружать, и значения подбирать - все одно и тоже... Голову сломал уже! Буду крайне благодарен за хоть какую-то подсказку! </p><p>Мне кажется что проблема именно в коде, что-то не правильно он интерпертирует, поскольку все остальное - отображение надписей на дисплее,&nbsp; и работа реле работает четко. А подключить там что-то не так невозможно.. вход через конденсатор на a2...</p><p> <span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2021/12/7559370049ccd554e51c707c70e771ad.png" alt="http://forum.rcl-radio.ru/uploads/images/2021/12/7559370049ccd554e51c707c70e771ad.png" /></span> <span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2021/12/1a6217b4da48ca6a0a4a65b9e7b84bf8.png" alt="http://forum.rcl-radio.ru/uploads/images/2021/12/1a6217b4da48ca6a0a4a65b9e7b84bf8.png" /></span> </p><br /><br /><div class="codebox"><pre><code>#define AUTO_GAIN 0      // автонастройка по громкости
  #define VOL_THR 35        // порог тишины (ниже него отображения на матрице не будет)
  #define LOW_PASS 30       // нижний порог чувствительности шумов (нет скачков при отсутствии звука)
  #define DEF_GAIN 80       // максимальный порог по умолчанию 
  #define FHT_N 256         // ширина спектра х2
  #define LOG_OUT 1
  #include &lt;FHT.h&gt; 
  #include &lt;EEPROM.h&gt;
  #include &lt;Wire.h&gt; 
  #include &lt;LiquidCrystal.h&gt;
  #define PIN_RELAY 2
  #define AUDIO_IN 16

 #define printByte(args) write(args);
   double prevVolts = 100.0;
   // --------------- БИБЛИОТЕКИ ---------------
   #define cbi(sfr, bit) (_SFR_BYTE(sfr) &amp;= ~_BV(bit))
   #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
      LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
      byte posOffset[20] = {10, 16, 18, 20, 24, 30, 34, 40, 44, 50, 54, 56, 58, 60, 62, 64, 68, 70, 72, 74}; // вч выш
      byte maxValue, maxValue_f,ww=1,gain_sp = DEF_GAIN;
      float k = 0.1;
      int i1,yyy,spek;
      unsigned long gainTimer;

      
   
void setup(){
   Serial.begin(9600);Wire.begin();lcd.begin(20,4);// LCD 20X4
   pinMode(12,INPUT);
  sbi(ADCSRA, ADPS2);
  cbi(ADCSRA, ADPS1);
  sbi(ADCSRA, ADPS0);
   analogReference(EXTERNAL);
   spek = EEPROM.read(100);
   lcd.print(&quot;MUTED, please wait..  &quot;);delay(200);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(150);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(100);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(50);
   lcd.print(&quot;*&quot;);delay(300);

   lcd.clear();
   
   pinMode(PIN_RELAY, OUTPUT); // Объявляем пин реле как выход
  digitalWrite(PIN_RELAY, HIGH); // Выключаем реле - посылаем высокий сигнал
   lcd.print(&quot;                       ON AIR! ENJOY!&quot;);delay(200);
   
  
   
   
}



 void loop(){
   if(digitalRead(12)==HIGH){spek++;EEPROM.update(100,spek); ww=1;if(spek&gt;5){spek=0;}delay(300);}

    
      if(spek==0&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 14};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 14, 14};
      byte v3[8] = {0, 0, 0, 0, 0, 14, 14, 14};
      byte v4[8] = {0, 0, 0, 0, 14, 14, 14, 14};
      byte v5[8] = {0, 0, 0, 14, 14, 14, 14, 14};
      byte v6[8] = {0, 0, 14, 14, 14, 14, 14, 14};
      byte v7[8] = {0, 14, 14, 14, 14, 14, 14, 14};
      byte v8[8] = {14, 14, 14, 14, 14, 14, 14, 14};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

       if(spek==1&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 4};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 4, 4};
      byte v3[8] = {0, 0, 0, 0, 0, 4, 4, 4};
      byte v4[8] = {0, 0, 0, 0, 4, 4, 4, 4};
      byte v5[8] = {0, 0, 0, 4, 4, 4, 4, 4};
      byte v6[8] = {0, 0, 4, 4, 4, 4, 4, 4};
      byte v7[8] = {0, 4, 4, 4, 4, 4, 4, 4};
      byte v8[8] = {4, 4, 4, 4, 4, 4, 4, 4};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}



      if(spek==2&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 10};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 10, 10};
      byte v3[8] = {0, 0, 0, 0, 0, 10, 10, 10};
      byte v4[8] = {0, 0, 0, 0, 10, 10, 10, 10};
      byte v5[8] = {0, 0, 0, 10, 10, 10, 10, 10};
      byte v6[8] = {0, 0, 10, 10, 10, 10, 10, 10};
      byte v7[8] = {0, 10, 10, 10, 10, 10, 10, 10};
      byte v8[8] = {10, 10, 10, 10, 10, 10, 10, 10};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==3&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 27};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 27, 27};
      byte v3[8] = {0, 0, 0, 0, 0, 27, 27, 27};
      byte v4[8] = {0, 0, 0, 0, 27, 27, 27, 27};
      byte v5[8] = {0, 0, 0, 27, 27, 27, 27, 27};
      byte v6[8] = {0, 0, 27, 27, 27, 27, 27, 27};
      byte v7[8] = {0, 27, 27, 27, 27, 27, 27, 27};
      byte v8[8] = {27, 27, 27, 27, 27, 27, 27, 27};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==4&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 31};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 31, 31};
      byte v3[8] = {0, 0, 0, 0, 0, 31, 31, 31};
      byte v4[8] = {0, 0, 0, 0, 31, 31, 31, 31};
      byte v5[8] = {0, 0, 0, 31, 31, 31, 31, 31};
      byte v6[8] = {0, 0, 31, 31, 31, 31, 31, 31};
      byte v7[8] = {0, 31, 31, 31, 31, 31, 31, 31};
      byte v8[8] = {31, 31, 31, 31, 31, 31, 31, 31};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

      if(spek==5&amp;&amp;ww==1){
      byte v1[8] = {0, 0, 0, 0, 0, 0, 0, 21};
      byte v2[8] = {0, 0, 0, 0, 0, 0, 21, 21};
      byte v3[8] = {0, 0, 0, 0, 0, 21, 21, 21};
      byte v4[8] = {0, 0, 0, 0, 21, 21, 21, 21};
      byte v5[8] = {0, 0, 0, 21, 21, 21, 21, 21};
      byte v6[8] = {0, 0, 21, 21, 21, 21, 21, 21};
      byte v7[8] = {0, 21, 21, 21, 21, 21, 21, 21};
      byte v8[8] = {21, 21, 21, 21, 21, 21, 21, 21};
      lcd.createChar(0, v1);lcd.createChar(1, v2);lcd.createChar(2, v3);lcd.createChar(3, v4);lcd.createChar(4, v5);lcd.createChar(5, v6);lcd.createChar(6, v7);lcd.createChar(7, v8);
      ww=0;}

    
      analyzeAudio();   // функция FHT, забивает массив fht_log_out[] величинами по спектру

      for (int pos = 0; pos &lt; 20; pos++) {  
        if (fht_log_out[posOffset[pos]] &gt; maxValue) maxValue = fht_log_out[posOffset[pos]];
        
        
        
        int posLevel = map(fht_log_out[posOffset[pos]], LOW_PASS, gain_sp, 0, 31);
        posLevel = constrain(posLevel, 0, 31);

   if(posLevel&lt;7){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 1);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 2);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)posLevel);}
   
   if(posLevel&gt;7&amp;&amp;posLevel&lt;15){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 1);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);lcd.setCursor(pos, 2);lcd.write((uint8_t)posLevel-8);}

   if(posLevel&gt;15&amp;&amp;posLevel&lt;23){
    lcd.setCursor(pos, 0);lcd.print(&quot; &quot;);
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 2);lcd.write((uint8_t)7);lcd.setCursor(pos, 1);lcd.write((uint8_t)posLevel-16);}    

   if(posLevel&gt;23&amp;&amp;posLevel&lt;31){
    lcd.setCursor(pos, 3);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 2);lcd.write((uint8_t)7);
    lcd.setCursor(pos, 1);lcd.write((uint8_t)7);lcd.setCursor(pos, 0);lcd.write((uint8_t)posLevel-24);}           
      }


   if (AUTO_GAIN) {
    maxValue_f = maxValue * k + maxValue_f * (1 - k);
    if (millis() - gainTimer &gt; 10) {   
    if (maxValue_f &gt; VOL_THR) gain_sp = maxValue_f;
      else gain_sp = 100;
      gainTimer = millis();}
      else {gain_sp = DEF_GAIN;}}
  }// loop

void analyzeAudio() { 
 for (int i = 0 ; i &lt; FHT_N ; i++) {
    int sample = analogRead(AUDIO_IN);
    fht_input[i] = sample; // put real data into bins
    
 }
    fht_window(); // window the data for better frequency response
    fht_reorder(); // reorder the data before doing the fht
    fht_run(); // process the data in the fht
    fht_mag_log(); // take the output of the fht
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[demartin]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1579</uri>
			</author>
			<updated>2021-12-13T22:05:15Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=4920#p4920</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Анализатор спектра LCD2004]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=4884#p4884" />
			<content type="html"><![CDATA[<p>Все режимы от кнопки работают. Оставлю управление по&nbsp; i2c. Снимать доп. плату не хочу, может и куплю другой дисплей. Автору спасибо за советы!</p>]]></content>
			<author>
				<name><![CDATA[samand587]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1417</uri>
			</author>
			<updated>2021-11-26T13:12:57Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=4884#p4884</id>
		</entry>
</feed>
