<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[forum.rcl-radio.ru &mdash; DC max]]></title>
	<link rel="self" href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=393&amp;type=atom" />
	<updated>2021-07-13T16:40:33Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.rcl-radio.ru/viewtopic.php?id=393</id>
		<entry>
			<title type="html"><![CDATA[DC max]]></title>
			<link rel="alternate" href="http://forum.rcl-radio.ru/viewtopic.php?pid=4354#p4354" />
			<content type="html"><![CDATA[<p>Здравствуйте. <br />В первой программе все работает как надо - измеритель постоянного напряжения с &quot;hold&nbsp; &quot; максимального напряжения<br /></p><div class="codebox"><pre><code>const int analogIn = PA7;
float U1 = 0.0;
float maxValue = 0;
int button = PB12;
#include &lt;LiquidCrystal.h&gt;

LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);

float val = 0;// define the variable as value=0

void setup()

{
  lcd.begin(16, 2);
  pinMode(button, INPUT_PULLUP);
}

void loop()
{
  val = analogRead(PA7);
  U1 = (val * 3.3 / 4096.0 );

  if (val &gt; maxValue)
  {
    maxValue = val;
  }
  if (digitalRead(PB12) == LOW)
  {
    maxValue = 0;
  }
   lcd.clear();
   lcd.setCursor(0,0); // Column, line
   lcd.print(&quot;M1&quot;);
   lcd.setCursor(0,1);
   lcd.print(U1);
  
  lcd.setCursor(9, 0);
  lcd.print(maxValue* 3.3/4096.0 );

  delay(200); //Wait for 200ms

}</code></pre></div><p> добавил её до второй, но она не реагирует на изменение напряжения на PA7.</p><div class="codebox"><pre><code>#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);

const int analogIn = PA7;
float U1 = 0.0;
float maxValue = 0;
float val = 0;// define the variable as value=0
int button = PB12;
int WhichScreen = 1;  // This variable stores the current Screen number
boolean hasChanged = true;
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup()
{
  lcd.begin(16, 2);
  pinMode(PB11, INPUT);
  pinMode(button, INPUT_PULLUP);

}
void loop()
{
  ////////////
  val = analogRead(PA7);
  U1 = (val * 3.3 / 4096.0 );

  if (val &gt; maxValue)
  {
    maxValue = val;
  }
  if (digitalRead(PB12) == LOW)
  {
    maxValue = 0;
  }
  /*
    lcd.print(&quot;     &quot;);
    lcd.setCursor(0, 0);
    lcd.print(U1);

    lcd.setCursor(9, 0);
    lcd.print(maxValue* 3.3/4096.0 );
  */
  // lcd.print(&quot;     &quot;);
  // delay(200); //Wait for 200ms
  //////////////

  if (hasChanged == true) {

    switch (WhichScreen) {
      case 1:
        {
          firstScreen();
        }
        break;

      case 2:
        {
          secondScreen();
        }
        break;

      case 3:
        {
          thirdScreen();
        }
        break;

      case 4:
        {
          fourthScreen();
        }
        break;

      case 5:
        {
          fifthScreen();
        }
        break;

      case 6:
        {
          sixthScreen();
        }
        break;
      case 0:
        {

        }
        break;
    }
  }

  //-------------------------------
  // BEGIN of the switch debouncing code
  int reading = digitalRead(PB11);
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) &gt; debounceDelay) {
    // whatever the reading is at, it&#039;s been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        hasChanged = true;
        WhichScreen++;


      }
    } else {
      hasChanged = false;
    }
  }
  lastButtonState = reading;
  // END of the switch Debouncing code
  // --------------------------------------
  if (WhichScreen &gt; 6) {
    WhichScreen = 1;
  }
}

void firstScreen()
{

  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M1&quot;);
  lcd.setCursor(0, 1);
  lcd.print(U1);

  lcd.setCursor(9, 1);
  lcd.print(maxValue * 3.3 / 4096.0 );
  ///////////
}
void secondScreen()
{
  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M2&quot;);
  lcd.setCursor(0, 1);
  lcd.print(&quot;M2 b&quot;);
}
void thirdScreen()
{
  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M3&quot;);
  lcd.setCursor(0, 1);
  lcd.print(&quot;M3b&quot;);
}
void fourthScreen()
{
  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M4&quot;);
  lcd.setCursor(0, 1);
  lcd.print(&quot;M4 b&quot;);
}
void fifthScreen()
{
  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M5&quot;);
  lcd.setCursor(0, 1);
  lcd.print(&quot;M5 b&quot;);
}
void sixthScreen()
{
  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M av&quot;);
  lcd.setCursor(0, 1);
  lcd.print(&quot;M avb&quot;);
}</code></pre></div><p>Вот здесь всё мертво</p><div class="codebox"><pre><code>void firstScreen()
{

  lcd.clear();
  lcd.setCursor(0, 0); // Column, line
  lcd.print(&quot;M1&quot;);
  lcd.setCursor(0, 1);
  lcd.print(U1);

  lcd.setCursor(9, 1);
  lcd.print(maxValue * 3.3 / 4096.0 );
  ///////////
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[galina]]></name>
				<uri>http://forum.rcl-radio.ru/profile.php?id=1049</uri>
			</author>
			<updated>2021-07-13T16:40:33Z</updated>
			<id>http://forum.rcl-radio.ru/viewtopic.php?pid=4354#p4354</id>
		</entry>
</feed>
