a digital potentiometer using mcp4131 and wemos D1 mini

194 views
Skip to first unread message

mohamed Abdulmajid

unread,
Jul 12, 2021, 5:29:39 PM7/12/21
to TasmotaUsers
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);
}

Philip Knowles

unread,
Jul 12, 2021, 11:41:21 PM7/12/21
to TasmotaUsers, mohamed Abdulmajid
As far as I know the only SPI devices supported are displays. You may be able to modify the display driver code to achieve what you want. You could maybe use PWM to control the brightness of the LED without the MCP4131. You may need to drive via a transistor if the LED draws too much power.

Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of mohamed Abdulmajid <gomaamo...@gmail.com>
Sent: Monday, July 12, 2021 10:29:39 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: a digital potentiometer using mcp4131 and wemos D1 mini
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/f9a114cc-6f63-4815-8062-13dcd302e894n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages