Teaching Assistant / Mbed 2 deprecated PWM_generator

Dependencies:   mbed

main.cpp

Committer:
302Instructor
Date:
2015-01-22
Revision:
0:0cb6f477149a

File content as of revision 0:0cb6f477149a:

#include "mbed.h"

void countDirection(int);
DigitalOut steering_pwm(PTE20);
int count = 0;
int ref = 120e3;
int countDir = 0;

/*void countDirection(int)
{
    if (countDir = 0) {
        count++;
    } else (countDir = 1) {
        count--;
    }
}*/

int main()
{
    while(1) {
        if (count == 1) {
            countDir = 0;
        }   else if(count == 240e3){
            countDir = 1;
        }

        if (countDir == 0) {
            count+=1;
        } else if (countDir == 1) {
            count+=-1;
        }

        if (count <= ref) {
            steering_pwm = 1;
        } else {
            steering_pwm = 0;
        }
    }
}