Arduino Sketch跳过while语句

时间:2018-08-13 13:39:31

标签: arduino arduino-uno

嗨,我在arduino草图的特定部分遇到了麻烦。

当我对其进行测试时,一切都很好,但是代码从不希望进入while循环。

 NumberzeroToNine = 0;
while(stepeight == 0)
{
  stepeight = digitalRead(ButtonPin);


lcd.clear();
lcd.setCursor(6,0);
lcd.print("Type in");
lcd.setCursor(1,1);
lcd.print("Amount Used");
lcd.setCursor(0,2);
 AddState = digitalRead(addPin);
  moveState = digitalRead(movepin);

if (AddState == 0)
  {

  lcd.print(NumberzeroToNine);
  delay(200);
  }
  else
  {
    NumberzeroToNine =  NumberzeroToNine + 1;

    lcd.print(NumberzeroToNine);
    delay(200);

  }
    if(moveState == 0)
    {


    }
    else
    { 
      float i = custom.read();
      lcd.clear();
      lcd.setCursor(6,0);
      lcd.print("Type in");
      lcd.setCursor(1,1);
      lcd.print("Amount Used");
      lcd.setCursor(0,2);
      lcd.print(NumberzeroToNine);
      delay(200);
      calweight = NumberzeroToNine;
      lcd.clear();
      lcd.print(NumberzeroToNine);
      delay(2000);
      raw_value = i;
      float z =  raw_value - zerocount;
      lcd.clear();
      lcd.print(i);
      delay(2000);
      float j;
      float e;
      float r;
      float t = 1;
      float y;
      y = (NumberzeroToNine * 1000);

      while(t < y)
      {
        lcd.clear();
        lcd.print(t);
        delay(1000);
        t = i * workaround;
        r = workaround + 0.01;
        workaround = r;

      }

      workaround = r * 1000;

      e = NumberzeroToNine * workaround;
      r = (i / y);
      myfactor = r;


    }

}

在我测试的示例中,我在此块中所有变量均为浮点数,变量t设置为1且y设置为2000,它不会输入或运行while语句的任何部分。 不会输入的部分是

while(t < y)
      {
        lcd.clear();
        lcd.print(t);
        delay(1000);
        t = i * workaround;
        r = workaround + 0.01;
        workaround = r;

      }

有什么想法我要去哪里吗? 我添加了变量r,因为我无法正常工作

0 个答案:

没有答案