gpt4 book ai didi

c++ - 打印led程序出现问题

转载 作者:行者123 更新时间:2023-12-03 07:22:42 24 4
gpt4 key购买 nike

假设每次LED在串行绘图仪/命令框中闪烁时,它就会缩紧
喜欢
1个
2
3
4
5
但只显示10次

int ledPin = 11;
int blinkTime = 700;
int timesBlinked = 0;


void setup()
{
pinMode(11, OUTPUT);
blinkyBlinky(10, blinkTime); // 10 is number of blinks, blinkTime is the milliseconds in each state from above: int blinkTime = 500;
Serial.begin(9600);
Serial.print(timesBlinked, DEC);
timesBlinked++;

Serial.setTimeout(500);

}

void loop()
{



}

void blinkyBlinky(int repeats, int time){

for (int i = 0; i < repeats; i++)
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
Serial.println(timesBlinked, DEC);
timesBlinked++;
}
}
用于命令

最佳答案

你打过电话了

blinkyBlinky(10, blinkTime);
之前
Serial.begin(9600);
你不能用
Serial.println(timesBlinked, DEC);
之前
Serial.begin(9600);
被称为。
交换 setup中的行:
void setup()
{
pinMode(11, OUTPUT);
Serial.begin(9600);
blinkyBlinky(10, blinkTime); // 10 is number of blinks, blinkTime is the milliseconds in each state from above: int blinkTime = 500;
Serial.print(timesBlinked, DEC);
timesBlinked++;

Serial.setTimeout(500);

}

关于c++ - 打印led程序出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64627850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com