Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Low_Cost_PWM by
Main.cpp
- Committer:
- Racer01014
- Date:
- 2014-09-08
- Revision:
- 0:13b8e78aee30
- Child:
- 1:dadef2f723e4
File content as of revision 0:13b8e78aee30:
#include "mbed.h"
//*******************************************
//****INPUTS*********************************
PwmOut Motor_Fet(p21);
DigitalIn Light_Barrier(p17);
//*******************************************
//****MAIN***********************************
int main()
{
bool Light_stop = 0;
int counter = 0, RPM_S = 0;
Motor_Fet.period_us(20000);
Motor_Fet.pulsewidth_us(200);
//***************((((((((((((((()))))))))))))
//***MAIN-PROG***((((((((((((((()))))))))))))
while(1)
{
//**************************LIGHTBARRIER*******************************
if (!Light_Barrier) //Detects Falling Edge of the Light_Barrier
{
if (!Light_stop) //Asures First Run since detected Edge
{
counter++;
Light_stop = 1; //Asures just one counter-increase per Falling Edge -> Locks counter increase
}
}
else
Light_stop = 0; //Unlocks counter-increase when theres no falling edge
//**************************LIGHTBARRIER*******************************
//**************************Specified-rpm******************************
}
}
