Hello everyone,
I'm trying to use this digital potentiometer MCP4021 with an Arduino duemilanove
you can see the datasheet at this web:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en022386
in concrete the 5kohm one
the comunication interface is up or down, so I have to implement the
code to comunicate with this device. The communication is through 2
pins, which increment or decrement the value of the resistance of the wiper
The datasheet explains how to comunicate with this device, with this graph:
the times you see on this graph are defined in this table:
so I tried to code this with the following result
int ud=1;
int cs=2;
void setup(){
pinMode(ud,OUTPUT);
pinMode(cs,OUTPUT);
}
void loop(){
digitalWrite(cs,HIGH);
digitalWrite(ud,LOW);
delay(1000)
digitalWrite(ud,HIGH);
delayMicroseconds(0.5);
digitalWrite(cs,LOW);
delayMicroseconds(0.5);
digitalWrite(ud,LOW);
delayMicroseconds(0.5);
digitalWrite(ud,HIGH);
delayMicroseconds(0.5);
digitalWrite(ud,LOW);
delayMicroseconds(0.5);
digitalWrite(ud,HIGH);
delayMicroseconds(0.5);
digitalWrite(cs,HIGH);
delayMicroseconds(0.5);
digitalWrite(ud,LOW);
digitalWrite(cs,LOW);
delay(5000);
}
I have also tried to change the delayMicroseconds value, because 0.5
seemed it could represent an error, but same thing hapends, nothing,
the resistance value doesn't move.
See if you know what I'm doing wrong,
thanks for your attention.