树莓派PICO流速计的MicroPython的代码实现-如何由C转为Micropython?

Eukaryota 2022-06-16938 次点击
背景:
最近在学树莓派PICO的Micropython,买了一个流速计YF-S401,参考资料见链接,这里用C语言已经实现了,但是我对C语言不熟悉,想请大佬没根据这段代码,转化为树莓派PICO的Micropython能实现的脚本,请帮忙!!!

arduino ide样例代码(C语言实现代码)
(https://wiki.dfrobot.com.cn/_SKU_SEN0216__%E6%B0%B4%E6%B5%81%E9%87%8F%E8%AE%A1-1_8_)
```
/***************************************************
This example reads Water flow sensor Sensor.

Created 2016-3-13
By berinie Chen <bernie.chen@dfrobot.com>

GNU Lesser General Public License.
See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/

/***********Notice and Trouble shooting***************
1.Connection and Diagram can be found here http://wiki.dfrobot.com.cn/index.php?title=(SKU:SEN0216)_%E6%B0%B4%E6%B5%81%E9%87%8F%E8%AE%A1-1/8%E2%80%B3#.E6.8E.A5.E7.BA.BF.E5.9B.BE
2.This code is tested on Arduino Uno.
****************************************************/
volatile double waterFlow;
void setup() {‌‌‌
Serial.begin(9600); //baudrate
waterFlow = 0;
attachInterrupt(0, pulse, RISING); //DIGITAL Pin 2: Interrupt 0
}
void loop() {‌‌‌
Serial.print("waterFlow:");
Serial.print(waterFlow);
Serial.println(" L");
delay(500);
}

void pulse() //measure the quantity of square wave
{‌‌‌
waterFlow += 1.0 / 5880.0;
}
```
收藏 ♥ 感谢
Spoony 小组长 2022-06-16 
不会就学吧,这几句都没用到什么语法,会英文就能试试。
Python 参考:
https://micropython.nxez.com/docs/a-byte-of-python/zh-cn/index.html
http://docs.micropython.org/

然后让卖家提供流速计基于 Python 封装的库,如果他有的话。说不定他还能给你 Python 的 Demo。
店长大人 8.5m 2022-06-16 
当0口监测到有个外部高电平信号,调用用中断程序,终端程序里面就一个以和赋值?还是固定值,来一个脉冲加一个1/5880,挺有意思

登录注册 后可回复。



GitHub