Skip to content

Instantly share code, notes, and snippets.

@tiagohm tiagohm/MCP41XXX.c
Created Mar 1, 2018

What would you like to do?
Potenciometro Digital de 256 posições e 1 canal.
MCP41XXX - Potenciometro Digital de 256 posições e 1 canal.
Autor: Tiago Melo
Blog: Microcontrolandos
Compilador: MikroC PRO PIC
Bibliotecas: Soft_SPI
//Pinos do MCP41XXX.
sbit SoftSpi_SDI at RB1_bit;
sbit SoftSpi_SDO at RB1_bit;
sbit SoftSpi_CLK at RB0_bit;
sbit SoftSpi_SDI_Direction at TRISB1_bit;
sbit SoftSpi_SDO_Direction at TRISB1_bit;
sbit SoftSpi_CLK_Direction at TRISB0_bit;
sbit MCP41XXX_CS at RB2_bit;
sbit MCP41XXX_CS_Direction at TRISB2_bit;
void MCP41XXX_Init() {
//Inicia o pino CS como saída e valor inicial = 1.
MCP41XXX_CS_Direction = 0;
MCP41XXX_CS = 1;
void MCP41XXX_Write(char valor) {
MCP41XXX_CS = 0;
//Define o valor do potenciômetro 0.
MCP41XXX_CS = 1;
void main() {
char valor = 0;
//Inicia a comunicação SPI.
//Inicializa o MCP41XXX.
while(1) {
//Define o valor do potenciômetro.
//Faz nada por 100ms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.