作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直忙于 PIXYCAM 和 Arduino Uno,我从他们的网站下载了下面的代码。现在有一个(i%50)操作,我不知道它的作用是什么?有人可以帮我解释一下这部分代码吗?
#include <SPI.h>
#include <Pixy.h>
Pixy pixy;
void setup()
{
Serial.begin(9600);
Serial.print(“Starting...\n”);
pixy.init();
}
void loop()
{
static int i = 0;
int j;
uint16_t blocks;
char buf[32];
blocks = pixy.getBlocks();
if (blocks)
{
i++;
if (i%50==0)
{
sprintf(buf, “Detected %d:\n”, blocks);
Serial.print(buf);
for (j=0; j<blocks; j++)
{
sprintf(buf, “ block %d: “, j);
Serial.print(buf);
pixy.blocks[j].print();
}
}
}
}
最佳答案
当 i 是 50 的整数倍时,它执行 if 子句的内容,因此当 i = 50, 100, 150, ... 时表达式为 true
我对 PIXYCAM 一无所知,但代码似乎每隔一段时间就会打印一组 block ......
关于c - Pixy CMUCAM5 开源示例代码 模运算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29644660/
我是一名优秀的程序员,十分优秀!