![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
prueba1
Dependencies: mbed motoresDC TextLCD SLCD
main.cpp
- Committer:
- 20172573063
- Date:
- 2020-06-22
- Revision:
- 0:465ff75162d5
- Child:
- 1:e51f299dd462
File content as of revision 0:465ff75162d5:
#include "mbed.h" #include "rtos.h" #include "motoresDC.h" MotoresDC carro(D8,D10, D11, D9, D12, D13); int pulso=0,num; Thread thread; Thread thread1; Thread thread2; void motor_ascend() { while(1) { if(pulso==1) { switch(num) { case '1': carro.conducir(0.3); break; case '2': carro.conducir(0.5); break; case '3': carro.conducir(0.7); break; case '4': carro.conducir(1); break; case '5': NVIC_SystemReset (); break; } Thread::wait(50); } } } void motor_descend() { while(1) { if(pulso==1) { switch(num) { case '4': carro.conducir(0.3); break; case '3': carro.conducir(0.5); break; case '2': carro.conducir(0.7); break; case '1': carro.conducir(1); break; case '5': NVIC_SystemReset (); break; } Thread::wait(50); } } } void cambio() { while(1) { if(pulso==1) { if(num==1) { Thread::wait(2000); num++; } if(num==2) { Thread::wait(2000); num++; } if(num==3) { Thread::wait(2000); num++; } if(num==4) { Thread::wait(6000); num++; } } } } int main() { thread.start (cambio); thread1.set_priority (osPriorityNormal1); thread1.start(motor_ascend); thread2.set_priority (osPriorityNormal1); thread2.start(motor_descend); }