读取写入方式分为数字和模拟

读取方式:(注意接地)

数字:digitalRead(pin);
 

模拟:
analogRead(A1);
float val=value*(5.0/1023.0);                  //  0·····1023

 

写入方式:

数字:digitalWrite(pin,HIGH/LOW);

 

模拟:analogWrite(pwm,0·255);   //  这里涉及脉冲宽度调制,与占空比方波有关,如果要去读取对应pin值推荐用万用表,如果利用digitalRead(pin);会得到不稳定的0或者1,数量取决于0---255这个数字

例如:

 analogWrite(3,128);

 value=digitalRead(5);

Arduino读取写入电压值

 

相关文章:

  • 2021-12-22
  • 2021-08-02
  • 2022-12-23
  • 2021-10-02
  • 2022-02-01
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2022-01-24
  • 2021-11-30
  • 2021-04-17
  • 2021-10-02
  • 2022-01-16
相关资源
相似解决方案