为什么这会在我的pi 4(beginer,第一个使用普通c的计时器)上显示一个不适合循环的错误


#include <wiringPi.h>
#include <stdio.h>
#define ledPin 0
main()
{
wiringPiSetup()
int x;
for(x=0; x<4; x+1)
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}
}    

错误在第7行,我已经坚持了2天了(我用geany编码(

  1. 听起来你在第8行遇到了一个编译错误:

    wiringPiSetup()  /* <-- You need to end the line with ";" */
    
  2. 你的循环应该是这样的:

    for(x=0; x<4; x++) {...} /* "x+1" doesn't change the value of "x", so the loop will never terminate */
    

问题出在for循环中。

for(x=0; x<4; x+1)

括号中的第三个参数没有任何作用。您可能想要递增x,您将使用x++x+=1来执行此操作。

x+1将返回该值,但该值不会存储在任何位置。

最新更新