Pesquisar neste blog

02/08/2020

Canal Analógico 3 com PIC 16F877A

Objetivo: Exibir em um display LCD o valor real da tensão aplicada

Código feito em CCS C Compiler:

#include <16f877a.h>
#device ADC = 8 //RESOLUÇÃO DE 8 BITS
#use delay(clock= 4MHz)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#include <lcd.c>

void main(void){
   float data, tensao;//bits
   
   
   SETUP_ADC_PORTS(AN0);
   SETUP_ADC(ADC_CLOCK_INTERNAL);//SINAL INTERNO PARA CONVERSÃO
   SET_ADC_CHANNEL(0);//SETANDO CANAL EM 0
   
   lcd_init();
   
   while(true){
      
      data = (float) (read_adc());//converte o valor analogico
      delay_ms(50);
      tensao = (5.0 / 255.0) * (data);//valor real da tensão
      printf(lcd_putc,"\f TENSAO = %f ",tensao);
      delay_ms(1000);
      
   }
}


Canal Analógico 2 com PIC 18F4550



















Código feito em CCS C Compiler

#include <18f4550.h>
#device ADC = 10//resolução de 10 bits
//#device ADC = 8 //RESOLUÇÃO DE 8 BITS
#fuses INTRC_IO, NOWDT, NOMCLR
#use delay(clock= 4MHz)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#include <lcd.c>

void main(){
   long data;//bits
   
   
   SETUP_ADC_PORTS(AN0_TO_AN1|VSS_VREF);//CANAL 1 | TENSÃO EXTERNA DE REFERÊNCIA
   SETUP_ADC(ADC_CLOCK_INTERNAL);//SINAL INTERNO PARA CONVERSÃO
   SET_ADC_CHANNEL(1);//SETANDO CANAL EM 1
   
   lcd_init();
   
   while(true){
      
      data = read_adc();//converte o valor analogico em binario
      delay_ms(50);
      printf(lcd_putc,"\f VALOR = %Lu ",data);
      delay_ms(500);
      
   }
}


Promise 03 em JavaScript

//Objetivo: gerar numeros entre
function gerarNumerosEnte(minmax) {
    if(min > max){
        [maxmin] = [minmax]
        const [xy] = a
    }

    //valor aleatório
    return new Promise(resolve => {
        const fator = max - min + 1
        const aleatorio = parseInt(Math.random() * fator) +min
        resolve(aleatorio)
    })
}

gerarNumerosEnte(520).then(console.log)

gerarNumerosEnte(740)
    //composição de função
    .then(num => num * 10)//número multiplicado por 10
    .then(numX10 => `O número gerado foi ${numX10}`)
    .then(console.log)//imprimindo o valor