#include "mbed.h"
Serial pc(SERIAL_TX, SERIAL_RX); Serial device(PB_6, PA_10);
DigitalIn mybutton(USER_BUTTON); DigitalOut LED(PA_5); DigitalOut RL1(PA_8); DigitalOut RL2(PB_10); DigitalOut RL3(PB_4); DigitalOut RL4(PB_5); #define NonPremuto 1 #define Premuto 0 void OnRELE_forTime(int Rele, float Tempo); int main() { while(1) { if (mybutton == Premuto) { LED = !LED; OnRELE_forTime(1, 2); OnRELE_forTime(2, 2); OnRELE_forTime(3, 2); OnRELE_forTime(4, 2); } } } void OnRELE_forTime(int Rele, float Tempo) { if (Rele == 1) { RL1 = 1; wait(Tempo); RL1 = 0; } if (Rele == 2) { RL2 = 1; wait(Tempo); RL2 = 0; } if (Rele == 3) { RL3 = 1; wait(Tempo); RL3 = 0; } if (Rele == 4) { RL4 = 1; wait(Tempo); RL4 = 0; } } |