Pesquisar neste blog

19/03/2023

Selecionar data e hora em HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="date"><br>
    <input type="datetime-local"><br>
    <input type="time">
</body>
</html>

Saída gerada






18/03/2023

Load com CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="5">
    <title>Load</title>

<style>
    body{
        display: flex;
        justify-content: center;
        align-items: center;        
    }
    .load_1{
        margin-top: 10px;
        width: 100px;
        height: 100px;
        border-top: 10px solid red;
        border-left: 10px solid blue;
        border-right: 10px solid green;
        border-bottom: 10px solid yellow;
        border-radius: 50%;
        /*animation: load 1s ease infinite;*/
        animation: load 1s linear infinite;
    }
    h2{
        margin: -88px;
    }
    @keyframes load {
        to{
            transform: rotate(1turn);
        }
    }
</style>
</head>
<body>
    <h2>Load</h2>
    <div class="load_1">
    </div>
</body>
</html>

Saída gerada





17/03/2023

Efeito de animação com CSS

Saída gerada






















<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Efeito de animação</title>
</head>
<style>
    body{
        margin: 0;
        padding: 0;
    }
    .container{
        width: 100%;
        height: 100vh;
        position: relative;
        background:  white;
    }
    .span-container{
        width: 100px;
        height: 100px;
        transform: translate(-50%, -50%);
        position: absolute;
        top: 42%;
        left: 45%;
    }
    span{
        display: block;
        position: absolute;
        width: 40%;
        height: 40%;
        border-radius: 50%;
        animation: speed 2s infinite ease-in-out;
    }
    .one{
        background: yellow;
        animation-delay: 2s;
    }
    .two{
        background: #a308ce;
        animation-delay: 1.5s;
    }
    .three{
        background:  greenyellow;
        animation-delay: 1s;
    }
    .four{
        background: orangered;
        animation-delay: .5s;
    }
    @keyframes speed{
    0%{
       transform: translate(0%);
       border-radius: 50%;
    }
    25%{
       transform: translate(150%) scale(0.5);
    }
       50%{
       transform: translate(150%, 150%);
       border-radius: 50%;
    }
    75%{
        transform: translate(0, 150%) scale(0.5);
        border-radius: 0%;
    }
}
</style>
<body>
    <div class="container">
        <div class="span-container">
            <span class="one"></span>
            <span class="two"></span>
            <span class="three"></span>
            <span class="four"></span>
        </div>
    </div>
</body>
</html>

16/03/2023

Loading animation com CSS

Saída gerada




















<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="10">
    <title>Campo elemento</title>
    <link rel="stylesheet" href="estilo.css">    
    <style>
        body{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        background-color: #000;
        background-color: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
    }
    h1{
        position: relative;
        color: #e77811;
        font-size: 4em;
        letter-spacing: 5px;
        border-bottom: 18px solid #333;
        line-height: 1.4;
        font-family: consolas;
        text-transform: uppercase;
    }

    h1::before{
        content: attr(data-text);
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        color: dodgerblue;
        border-bottom: 16px solid dodgerblue;
        animation: lod 4s linear infinite;
        overflow: hidden;
    }
    @keyframes lod{
        0% {
            width: 0;
        }
        100% {
            width: 100%;
        }
    }        
    </style>
         
</head>
<body>
    <h1 data-text="Loading...">Loading...</h1>
</body>
</html>

15/03/2023

Rotação preloader com CSS

Saída gerada no navegador



























<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="3">
    <title>Document</title>
</head>
<style>
    body{
        height: 100vh;
        display: grid;
        place-items: center;
    }
    .wrapper{
        width: 100px;
        height: 100px;
        position: relative;
    }
    .circle{
        position: absolute;
        left: 50%;
        top: 50%;
        width: calc(100% - 10px);
        height: calc(100% - 10px);
        transform: translate(-50%, -50%) rotate(0deg);
        border-radius: 50%;
        border: 5px solid;
        border-color: black black transparent transparent;
        animation: round 1s linear infinite;
        text-align: inherit;
    }
    .c2{
        border-color: transparent transparent red red;
        width: calc(100% - 30px);
        height: calc(100% - 30px);
       
    }
    @keyframes round {
        0%{
            transform: translate(-50%, -50%) rotate(0deg);
        }
        100%{
            transform: translate(-50%, -50%) rotate(calc(360deg * var(--i)));
        }
    }
</style>
<body>
    <div class="wrapper">
        <div class="circle c1" style="--i:1"></div>
        <div class="circle c2" style="--i:-1"></div>
    </div>
</body>
</html>

14/03/2023

Animação com texto usando CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="3">
    <title>Campo elemento</title>
   
       
    <style>
        #container{
            background-color: #000;

        }
        h1{
            -webkit-text-stroke: .5vh #fff;
            font-size: 30vw;
            font-weight: bold;
            text-align: center;
            text-transform: uppercase;
            background-image: url(img/energisa.jpg);
            background-clip: text;
            -webkit-background-clip: text;
            color: transparent;
            animation: text 10s ease alternate infinite;
        }
        @keyframes text{
            from{
                background-position: 0% 50%;
            }
            to{
                background-position: 100% 50%;
            }
        }
        .scale{
            transform: scale(1);
        }
    </style>
         
</head>

<body id="container">
    <div>
        <h1>Like !</h1>
    </div>
</body>
</html>

Saída gerada



13/03/2023

Imagem refletida com CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="5">
    <title>Imagem refletida</title>
    <link rel="stylesheet" type="text/css" href="estilo.css">

<style>
    .imagem{
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 20px;
    background: url(https://cdn.britannica.com/66/80466-050-2E125F5C/Arc-de-Triomphe-Paris-France.jpg?w=300) center;
    background-size: cover;
}
.imagem::before, .imagem::after{
    content: '';
    width: 100%;
    height: 100%;
    bottom: -220px;
    border-radius: inherit;
    position: absolute;
}
.imagem::before{
    background: inherit;
    opacity: .6;
    transform: scaleY(-1);
}
.imagem::after{
    background: linear-gradient(0deg, #fff,
     sT, #FFF0 100%);

}
</style>
</head>
<body>
    <div class="imagem"></div>
</body>
</html>

Saída gerada















12/03/2023

Limitar o campo da escrita em CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="refresh" content="3">
    <title>Campo elemento</title>
   
       
    <style>
        h1{
            width: 400px;
            border: 3px solid;
           
            white-space: nowrap;/*no final não quebre a linha*/
            overflow: hidden; /*se passar do limite vai esconder*/
            text-overflow: ellipsis; /*se passar coloca ...*/

        }
        .scale{
            transform: scale(1);
        }
    </style>
         
</head>

<body>
    <h1>Seja bem vindo ao Blog da Engenharia Codidiana</h1>
</body>
</html>

Saída gerada









Palavras chave:

Limit the field of writing in CSS
CSS дээр бичих талбарыг хязгаарлах
په CSS کې د لیکلو ساحه محدوده کړئ
Limit di fild fɔ rayt insay CSS
سی ایس ایس میں لکھنے کے شعبے کو محدود کریں۔
הגבל את תחום הכתיבה ב-CSS
Piirake CSS-is kirjutamisvälja
Begränsa fältet för att skriva i CSS

Prova 1 #2022/1

1.1. Crie um programa e faça as ligações necessárias para que os LED liguem e desliguem com frequências iguais as indicadas a seguir:

LED1 = 5Hz         Vi >= 0 e Vi  < 0,8v
LED2 = 10Hz         Vi >= 0,8 e Vi < 1,6v
LED3 = 20Hz         Vi >= 1,6 e Vi < 2,4v
LED4 = 50Hz         Vi >= 2,4 e Vi < 3,2v
LED5 = 100Hz Vi >= 3,2 e Vi < 4v
LED6 =                    Liga quando Vi >= 4v














Resolução feita no CCS C Compiler

#include <16F877A.h>
#device adc = 8
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT, NOWRT
#use delay(clock = 20MHz)
#include <lcd.c>
#use standard_io (b)
/*Crie um programa e faça as ligações para que os LED liguem e desliguem com 
frequências iguais as indicadas a seguir:
LED1 = 5HZz Vi >= 0V e Vi < 0,8V
LED2 = 10Hz Vi >= 0,8V e Vi < 1,6V
LED3 = 20HZ Vi >= 1,6 e Vi < 2,4V
LED4 = 50HZ Vi >= 2,4 e Vi < 3,2V
LED5 = 100HZ Vi >= 3,2 e Vi < 4V
LED6 = Liga quando Vi >= 4V
*/
unsigned int8 analog, frequencia, tempo;
float tensao;
unsigned int16 cont0 = 0, cont1 = 0, cont2 = 0, cont3 = 0, cont4 = 0, cont5 = 0;

#int_TIMER0
void TIMER0_isr(float tensao){
         
   if(tensao >= 0.01 && tensao < 0.8){
      printf(lcd_putc,"\fTENSAO = %1.2f V\nFREQ= 5 Hz", tensao);      
      if(++cont1 >= 1970) {cont1 = 0; output_toggle(PIN_B0);}   // 5HZ   ok
      
   }else if(tensao >= 0.80 && tensao < 1.60){
      printf(lcd_putc,"\fTENSAO = %1.2f V\nFREQ= 10 Hz", tensao); 
      if(++cont2 >= 750) {cont2 = 0; output_toggle(pin_B1);}   //10 HZ  ok
      
   }else if(tensao >= 1.60 && tensao < 2.40){
      printf(lcd_putc,"\fTENSAO = %1.2f V\nFREQ= 20 Hz", tensao); 
      if(++cont3 >= 240) {cont3 = 0; output_toggle(pin_B2);}   // 20 Hz  
      
   }else if(tensao >= 2.40 && tensao < 3.20){
      printf(lcd_putc,"\fTENSAO = %1.2f V\nFREQ= 50 Hz", tensao); 
      if(++cont4 >= 98) {cont4 = 0; output_toggle(pin_B3);}   // 50 Hz
      
   }else if(tensao >= 3.20 && tensao < 4.0){
      printf(lcd_putc,"\fTENSAO = %1.2f V\nFREQ= 100 Hz", tensao); 
      if(++cont5 >= 39) {cont5 = 0; output_toggle(pin_B4);}    // 100 Hz
   }else if(tensao >= 4.0){
      output_high(PIN_B5);
   }
   
}

void main(){
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);   
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED, 0, 1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_adc(ADC_CLOCK_DIV_32);           // Set ADC conversion time to 32Tosc
   setup_adc_ports(AN0);          // Configure AN0,AN1 and AN3 as analog   
   set_adc_channel(0);                    // Select channel AN1     
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   lcd_init();
   
   while(true) {
      analog = read_adc();
      tensao = (5.0 / 255.0) * analog;
      printf(lcd_putc,"\fTENSAO = %1.2f V\nT= %ums \tFREQ= %uHz",tensao, tempo, frequencia);
            
      TIMER0_isr(tensao);
            
   }
}


















































2. 2. Crie um programa e faça as ligações (cristal, resistor, alimentação, ...) necessárias para que os displays apresentem uma luz circulante no sentido horário (a, b, c, d, d', e', f', a', a, b,...). Onde d', e', f' e a', são segmento do display  catodo comum. A velocidade dependerá da posição do potenciômetro.















Resolução em código feito no CCS C Compiler

#include <16F877A.h>
#device adc = 8
#use delay(clock = 20MHz)
#FUSES HS,NOWDT,NOPROTECT,NOLVP

unsigned int8 vet1[] = {0b00001000, 0b00010000, 0b00100000, 0b00000001};
unsigned int8 vet2[] = {0b11111110, 0b11111101, 0b11111011, 0b11110111};

int size = sizeof(vet1)/sizeof(int); // tamanho do vetor vet1
unsigned int16 leia;

void main(void){
  setup_adc(ADC_CLOCK_DIV_32);           // Set ADC conversion time to 32Tosc
  setup_adc_ports(AN0_AN1_AN3);          // Configure AN0,AN1 and AN3 as analog
  setup_ccp2(CCP_PWM);                   // Configure CCP2 as a PWM
  setup_timer_2(T2_DIV_BY_16, 255, 1);   // Set PWM frequency to 488Hz
  set_adc_channel(0);                    // Select channel AN1
  
  while(true){
                        
      leia = read_adc();                 // Read from AN1 and store in j
      
      for(int i = 0; i < size; i++){
         output_d(vet1[i]);
         delay_ms(leia);
      }      
      
      for(int j = 0; j < size; j++){
         output_d(vet2[j]);
         delay_ms(leia);
      }
   }
}




3. Desenvolva um programa para acionar o motor de passo a seguir. Para girar no sentido 1 (b1, b2, b3, b4, b1, b2,...) e no sentido contrário devem ser acionadas as bobinas (b4, b3, b2, b1, b4, b3,...) Utilize um botão para inverter o sentido. O motor deve girar com velocidade de 100 rpm (rpm = rotações por minuto) no sentido horário e 75 rpm no sentido anti-horário.













Resolução feita no CCS C Compiler

#include <16F877A.h>
#fuses XT, HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock = 20MHz)
#include <lcd.c>

#define t1 150
#define t2 200

#use fast_io(B)

unsigned int horario[9] = {0b00010000, 0b00110000, 0b01110000, 0b01100000, 0b11100000, 0b11000000, 0b10000000, 0b10010000};
unsigned int antiHorario[9] = {0b10000000, 0b11000000, 0b01000000, 0b01100000, 0b00100000, 0b00110000, 0b00010000, 0b10010000};
int i = 0, cont = 0;

#INT_EXT
ext_isr(){
   cont++;
   if(cont >= 4) {cont = 0;}
}

void main(){
   set_tris_b(0x01);
   output_low(PIN_B7);
   port_b_pullups(TRUE);
   enable_interrupts(int_ext);
   ext_int_edge(L_TO_H);
   enable_interrupts(GLOBAL);
   
   lcd_init();
   
   while(true){
      printf(lcd_putc, "\fMOTOR OFF !");
      delay_ms(500);
   
      while(cont == 1){
         output_b(horario[i]);
         lcd_gotoxy(1, 1);
         delay_ms(t1);
         i++;
         if(++i >= 8) {i = 0;}
         
         lcd_gotoxy(1, 1);
         printf(lcd_putc, "\fMOTOR ON");
         lcd_gotoxy(1,2);
         printf(lcd_putc, "SENTIDO HORARIO");
         lcd_gotoxy(21,1);
         printf(lcd_putc, "Freq = 100 RPM");
         lcd_gotoxy(21,2);
         printf(lcd_putc, "Freq = 10.47 rad/s");
      }
   
      while(cont == 3){
         output_b(antiHorario[i]);
         delay_ms(t2);
         i++;
         if(++i >= 8) {i = 0;}
         
         lcd_gotoxy(1, 1);
         printf(lcd_putc, "\fMOTOR ON");
         lcd_gotoxy(1,2);
         printf(lcd_putc, "SENTIDO ANTI-HORARIO");
         lcd_gotoxy(21,1);
         printf(lcd_putc, "Freq = 75 RPM");
         lcd_gotoxy(21,2);
         printf(lcd_putc, "Freq = 7.85 rad/s");
      }
   }
}

Software Proteus versão 7.9
























10/03/2023

Comunicação serial com PIC 16F628A e 18F4550

Código feito em CCS C Compiler

Arquivo: 16F628A.c

#include <16F628A.h>
#fuses INTRC, NOWDT, NOMCLR
#use delay(clock = 4MHz)

#use rs232(baud= 9600, xmit= PIN_B2, rcv= PIN_B1)

void main(){
   
   int1 btn1, btn2, btn3;
   
   while(true){
      btn1 = input(PIN_A0);
      btn2 = input(PIN_A1);
      btn3 = input(PIN_A2);
      
      if( btn1 == 1 && btn2 == 0 && btn3 == 0 ){
         printf("#AUTO");
         
      }else if( btn1 == 0 && btn2 == 1 && btn3 == 0 ){
         printf("#ECONOMICO");
         
      }else if( btn1 == 0 && btn2 == 0 && btn3 == 1 ){
         printf("#DESEMPENHO");
         
      }
      
      delay_ms(1000);
   }
}


Arquivo: 18F4550.c

#include <18F4550.h>
#fuses INTRC, NOWDT, NOMCLR
#use delay(clock = 4MHz)

#use rs232(baud = 9600, xmit= PIN_C6, rcv= PIN_C7)
#include <lcd.c>

#INT_RDA
void serial_init(){
   char temp;
   
   while( kbhit() ){ // verificar se tem dados no banco
      temp = getc();
      if( temp == '#'){
         printf( LCD_PUTC, "\f");
      }else {
         printf(LCD_PUTC, "%c", temp);
      }
   }
}

void main(){
   
   lcd_init();
   
   enable_interrupts( GLOBAL );
   enable_interrupts( INT_RDA);
   
   printf( LCD_PUTC, "\fINICIANDO ...");
   delay_ms(1000);
   
   while(TRUE){
      
   }
}

Saída gerada no Proteus