Pesquisar neste blog

11/11/2022

Motor DC com PIC 16F877A

Controle de velocidade do motor DC
Botão 1: gira 90°
Botão 2: gira 45°
Botão 3: gira 15°

Código feito em CCS C Compiler

#include <16F877A.h>
#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT
#use delay(clock = 4MHz)

#define BOTAO1 PIN_B1
#define BOTAO2 PIN_B2
#define BOTAO3 PIN_B3

void main(){
   setup_timer_2(T2_DIV_BY_1, 249, 1);
   setup_ccp1(CCP_PWM);
   disable_interrupts(GLOBAL);
   port_b_pullups(TRUE);
   
   while(TRUE){
      if(!input(BOTAO1)){
         set_pwm1_duty(255);// 90°
         
      }else if(!input(BOTAO2)){// 45°
         set_pwm1_duty(153);
         
      }else if(!input(BOTAO3)){ // 15°
         set_pwm1_duty(51);
         
      }else{
         set_pwm1_duty(0);
      }
   }
}
























Tabelas com HTML

<!DOCTYPE html>
<html lang="pt-br">
<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>Tabelas</title>
</head>
<body>
<table>
<tr><th>A1</th> <th>A2</th> <th>A3</th> </tr>
<tr><th>B1</th> <th>B2</th> <th>B3</th> </tr>
<tr><th>C1</th> <th>C2</th> <th>C3</th> </tr>
</table>
</body>
</html>