José Antônio Bechara
/
APS1-Maquinas_e_Acionamentos
APS 1
main.cpp
- Committer:
- zezo
- Date:
- 2021-09-13
- Revision:
- 0:d08ae309693f
File content as of revision 0:d08ae309693f:
#include "mbed.h" PwmOut EN_A(D2); DigitalOut IN1A(D5); DigitalOut IN2A(D4); AnalogIn pot(A5); InterruptIn Encoder_interrupt(D3); float DC; float Va; int up; float w; Timer t; void contador() { up++; } int main() { while(1) { DC = pot.read(); EN_A.write(DC); IN1A = 1; IN2A = 0; Va = 12*DC; t.start(); Encoder_interrupt.rise(&contador); Encoder_interrupt.fall(&contador); if(t.read()>=0.5 ) { w = up/t.read(); printf("W = %1.2f rpm\n\r",w); printf("DC = %1.2f\n\r",DC,"V\n\r"); printf("Va = %1.2f V\n\r",Va); printf("\n\r"); up =0; t.reset(); } wait(0.001); } }