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

Dependencies:   mbed QEI MODSERIAL FastPWM ttmath Math

Motor_tryout.cpp

Committer:
viviien
Date:
2019-09-30
Revision:
5:fea5544804c1
Parent:
4:bd21569250c7
Child:
6:4dbd0d12e0f7

File content as of revision 5:fea5544804c1:

#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);
        }
    }
}
// Comment