磁気式ケイデンス計の電圧をanalogPinで読みます。INA226で電池電圧も読みます。
Dependencies: INA226_ver1 mbed
Diff: main.cpp
- Revision:
- 0:9e7b96a82406
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 09 09:10:28 2017 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "INA226.hpp" + +DigitalOut myled(LED1); + +I2C i2c(p9,p10); +INA226 VCmonitor(i2c,0x9C); +AnalogIn mgPin(p20); + +int main() { + unsigned short val; + double V; + val = 0; + if(VCmonitor.rawRead(0x00,&val) != 0){ + printf("VCmonitor READ ERROR\n"); + while(1){} + } + VCmonitor.setCurrentCalibration(); + + while(1) { + if(VCmonitor.getVoltage(&V) == 0){ + printf("e:%f\n",V); + } + printf("mgPin V:%f\n\r",mgPin.read()*3.3); + wait(0.1); + } +}