digital potentiometer using mcp4131 and wemos D1 mini

47 views
Skip to first unread message

mohamed Abdulmajid

unread,
Jul 12, 2021, 2:23:27 PM7/12/21
to esp8266-re
hello everyone , 
i'm trying to make a digital potentiometer to control the luminance of an LED using mcp4131 and wemos D1 mini. the mcp4131 digipot uses SPI communication. i have used a simple arduino code for testing, it worked with my arduino uno, but when i tried it with wemos D1 it doesn't work! 
- could anyone tell me where is the problem ??
- does tasmota support the mcp4131 digital potentiometer ? 
.
.
here is the simple arduino code :

#include <SPI.h>

byte address = 0x00;
int CS= 15;                // pin numper is 15 for wemos , 10 for arduino 

void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
}

void loop()
{
for (int i = 0; i <= 128; i++)
{
digitalPotWrite(i);
delay(10);
}
delay(500);
for (int i = 128; i >= 0; i--)
{
digitalPotWrite(i);
delay(10);
}
}

int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}
Reply all
Reply to author
Forward
0 new messages