![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
emg trial
Dependencies: FastPWM HIDScope MODSERIAL mbed biquadFilter
main.cpp
- Committer:
- s1680897
- Date:
- 2018-09-24
- Revision:
- 0:94b5c70f818b
- Child:
- 1:e81ca29ae626
File content as of revision 0:94b5c70f818b:
#include "mbed.h" #include "MODSERIAL.h" PwmOut pwmpin(D5); DigitalOut directionpin(D4); AnalogIn Pot_meter(A0); DigitalIn But2(D7); MODSERIAL pc(USBTX, USBRX); Ticker Ticker_direction; Ticker Ticker_But; //InterruptIn IntBut(D7); float x=0; void Potread() { x = Pot_meter.read(); pc.printf("%d\n\r",x); } void Direction() { float u = -0.3f; //determine useful value, -0.3f is just an example directionpin = u > 0.0f; //either true or false pwmpin = fabs(u); //pwm duty cycle can only be positive, floating point absolute value pc.printf("Test\r\n"); } int main() { pc.baud(115200); Ticker_direction.attach(Direction, 0.001); Ticker_But.attach(Potread,1); //IntBut.fall(Potread); pwmpin.period_us(60); //60 microseconds PWM period, 16.7 kHz while (true) { } }