Engenharia

344 palavras 2 páginas
#include

#define FALSE 0
#define TRUE 1

// Modifique o nome dos estados abaixo, e acrescente mais estados se necessário typedef enum
{
IDLE, RESFRIAMENTO, RESFRIAMENTO_INTERRUPTED, RESFRIAMENTO_COMPLETED, DOOR_OPENED_2, HELICE_ON,
} SMState_t;

int main(void)
{
// Declaração de entradas int forno = TRUE; int helice = FALSE; int timeButton = 60; int resp,tempe; tempe=0;

// Declaração de saídas // int forno = FALSE;
// int helice = TRUE; int timer = timeButton;

char refresh;

// Inicializa variável com estado inicial SMState_t SMState = IDLE; printf("Forno Ligado");

do{ tempe++; printf("Temperatura:%d",tempe,"ºC"); /* Ler as entradas printf("Atualizar entradas (s/n)?\n"); scanf("%c",&refresh); getchar();

if(refresh == 's') { printf("Digite em ordem: forno-(0/1)\n Helice-(0/1)\n"); scanf("%d,%d",&forno,helice); getchar(); printf("Entradas atualizadas: %d,%d\n",forno,helice); }*/

switch(SMState) { case IDLE: forno = TRUE; helice = FALSE; do{ tempe++; }while(tempe==65); if(forno == TRUE && tempe >= 65) { SMState = RESFRIAMENTO; //timer = tempe; } if(helice == TRUE) { SMState = HELICE_ON; } break;

case RESFRIAMENTO: helice = TRUE; forno = FALSE; do{ //timer = timer-1; tempe--; if(helice == FALSE) { SMState = RESFRIAMENTO_INTERRUPTED; } if(/*timer*/tempe == 60) { SMState = RESFRIAMENTO_COMPLETED; } }while(tempe==60); break; case RESFRIAMENTO_INTERRUPTED: forno = TRUE; helice = FALSE;

if(forno == TRUE && tempe >= 65) {

SMState = RESFRIAMENTO; //timer = tempe; }

if(helice == TRUE) { SMState = RESFRIAMENTO; } SMState=IDLE; break;

case RESFRIAMENTO_COMPLETED: forno = TRUE; helice = FALSE; do{ tempe++; if(forno == TRUE && tempe >= 65) { SMState = RESFRIAMENTO; timer = tempe; }

if(helice == TRUE) { SMState = HELICE_ON; } }while(tempe==65); /*

Relacionados

  • Engenharias
    2868 palavras | 12 páginas
  • engenharias
    1109 palavras | 5 páginas
  • A Engenharia
    867 palavras | 4 páginas
  • engenharia
    1100 palavras | 5 páginas
  • Engenharia
    3028 palavras | 13 páginas
  • O que é engenharia?
    802 palavras | 4 páginas
  • Engenharia
    3336 palavras | 14 páginas
  • Engenharia
    2578 palavras | 11 páginas
  • Engenharia
    828 palavras | 4 páginas
  • As engenharias
    12551 palavras | 51 páginas