Signa-bot code for project BioRobotics, at University of Twente.

Dependencies:   mbed QEI MODSERIAL FastPWM ttmath Math

Motor_tryout.cpp

Committer:
Feike
Date:
2019-09-30
Revision:
4:bd21569250c7
Child:
5:fea5544804c1
Child:
7:e119b12e5e7f

File content as of revision 4:bd21569250c7:

#include "mbed.h" 
#include "MODSERIAL.h"

DigitalOut motor1_pwm(D3);
MODSERIAL pc(USBTX, USBRX);
int main(void)
{   
    int frequency_pwm = 10000; //10 kHz PWM
    PwmOut motor1_pwm(D3);
    motor1_pwm.period(1.0/frequency_pwm); // T=1/f
    while(true)
    {
        for(int pct = 0 ; pct <= 100 ; pct = pct +10)
        {
            motor1_pwm.write(pct/100.0); // write Duty Cycle
            wait(0.1);
        }
    }
}