代码拉取完成,页面将自动刷新
int ndrdy = A4;
int clck = A5;
int pwm = 3;
void setup() {
Serial.begin(115200);
pinMode(pwm, OUTPUT);
while (!Serial) {}
digitalWrite(ndrdy, LOW);
pinMode(ndrdy, INPUT);
digitalWrite(clck, LOW);
pinMode(clck, OUTPUT);
while (digitalRead(ndrdy)) {}
while (!digitalRead(ndrdy)) {}
}
long readADC()
{
if (digitalRead(ndrdy))
return -1;
long result = 0;
for (int i = 0; i < 24; i++)
{
digitalWrite(clck, HIGH);
delayMicroseconds(1);
int new_bit = digitalRead(ndrdy);
digitalWrite(clck, LOW);
delayMicroseconds(1);
result <<= 1;
result |= new_bit;
}
for (int i = 0; i < 3; i++)
{
digitalWrite(clck, HIGH);
delayMicroseconds(1);
digitalWrite(clck, LOW);
delayMicroseconds(1);
}
return result;
}
void loop() {
long adcValue = readADC();
Serial.print("ADC reading: ");
Serial.print(adcValue);
if (adcValue >= 3400000)
{
delay(500);
analogWrite(pwm,0);
Serial.println(" End of Run ");
delay(500);
}
else
{
if (is_run == true)
{
analogWrite(pwm,255);
delay(500);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。