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.
Fork of TutoElectro_PWM by
main.cpp
- Committer:
- josedaparte
- Date:
- 2015-12-04
- Revision:
- 2:be4ea24f1cdd
- Parent:
- 1:778a662bafcf
- Child:
- 3:7de9f8f4a15e
File content as of revision 2:be4ea24f1cdd:
#include "mbed.h"
#include "TextLCD.h"
#include "AnalogIn.h"
PwmOut pwmsal(PTD2);
AnalogIn pwment(PTB1);
Serial pc(USBTX,USBRX);
float valorpwm;
TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
AnalogIn presionin(PTB3);
float caspresion;
int main()
{
while(1){
caspresion = presionin.read() * 3.3;
lcd.cls();
lcd.locate(0,1);
lcd.printf("%.2f",caspresion);
if(caspresion >= 2.34){
lcd.locate(0,0);
lcd.printf("maximo");
}
if(caspresion >= 1.68 && caspresion <= 1.85){
lcd.locate(0,0);
lcd.printf("medio");
}
if(caspresion <= 1.03){
lcd.locate(0,0);
lcd.printf("minimo");
}
pc.baud(115200);
pwmsal.period_ms(5);
valorpwm = pwment.read();
pwmsal.write(valorpwm);
wait(1);
}
}
