
Control de temperatura
Revision 3:3c2aa33f4e58, committed 2016-02-24
- Comitter:
- verden32
- Date:
- Wed Feb 24 01:10:19 2016 +0000
- Parent:
- 2:671794ada26d
- Commit message:
- Final parte 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Feb 22 03:41:37 2016 +0000 +++ b/main.cpp Wed Feb 24 01:10:19 2016 +0000 @@ -1,59 +1,66 @@ #include "mbed.h" Serial pc (USBTX, USBRX); -Serial bt (PTE22,PTE23); -AnalogIn lm35 (A1); -DigitalOut active (D4); //activador del control de temperatura +Serial bt (D14,D15); +AnalogIn lm35 (A4); +//DigitalOut active (D4); //activador del control de temperatura DigitalOut vent (D5); DigitalOut r (LED1); DigitalOut g (LED2); + +int ent; float voltaje; float temperatura; float lecturaPin; -char comp; +char select; int a; //vaciar ciclo TEMP int main() { while(1) { - - } - - - if(bt.readable()){ - comp = bt.scanf(); - } - if(active==1){ // Control para temperatura + + + if(r=0){ // Control para temperatura lecturaPin = lm35; voltaje = (lecturaPin*3300); // voltaje en mV, 3.3 en V temperatura= (voltaje/10); // por cada 10ms es = 1C° - comp= temperatura; + - bt.printf("+%.1f C",temperatura); - wait(.9); + bt.printf("+%.1f C",temperatura);// 43 ascii + wait(.9); - if(comp>=lm35){ - vent=0; - bt.printf("#warming up"); - wait(.5); + if(ent>=lm35){ + vent=0; + bt.printf("#Warming up");//35 ascii + wait(.5); } - if(comp==lm35){ - bt.printf("@Stable weather"); - wait(.5); - } - if(comp<lm35){ - vent=1; - bt.printf("+Cooling"); - wait(.5); - }else{ + if(ent==lm35){ + bt.printf("@Stable weather");//64 ascii + vent=0; + wait(.5); + }else{ a=20; } - - /*switch(select){ + if(ent<lm35){ + vent=1; + bt.printf("-Cooling");//45 ascii + wait(.5); + } + + + if(bt.readable()){ + select= bt.getc(); + } + switch(select){ - case'H':active=1;// Prender ventilador + case'H':r=0;// Prender ventilador + wait(.2); + if(bt.readable()){ + bt.scanf("%d",&ent); + wait(.2); + } break; - case'Z':active=0;// apagar ventilador + case'Z':r=1;// apagar ventilador vent=0; - break; - - }*/ + break; + } } +}} \ No newline at end of file