Digital potentiometer

I bought a bag with gadgets from "Arduinomodules". I have identified them all but one gadget that was not listed and is not to be found on arduinomodules.info. By that have I not found out the KY-XXX number for it.

It looks like a potentiometer, but is never ending when turned. Just small "tic" when one turn the "knob-arm". It has 5 Connection bones. GND, +, and Clk. Not har to understand. There are two more "SW" and "DT". What they stand for is a guess? (Maybe "DT" stands for "Data"? "SW" for direction?)

I am out to find out more of this gadget. How to Control it.

Does anyone here know something about the described gadget. Maybe solved the problem, or we can cooperate to find it out. I am just about to start testing. "Not because it's easy, because it's hard!" :slight_smile:

It sounds to me that it's likely a rotary encoder.

Does it look something like this?:

If so, it's probably a KY-040. Have a look at this document.

1 Like

Exactly!

I been "labing" with it all evening! :slight_smile:

int CLK = 8; //Define CLK pin, White
int SW = 12; //Define SW pin, Yellow
int DT = 11; //Define DT pin, Blue
int S = 0;
int D = 0;
void setup() {
// put your setup code here, to run once:

// Black = GND, + = RED
pinMode(CLK, OUTPUT); //OutPin White
pinMode(SW, INPUT); //InPin Yellow
pinMode(DT, INPUT); //InPin Blue
Serial.begin(115200);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, HIGH);
S = digitalRead(SW);
D = digitalRead(DT);
Serial.print("SW= ");
Serial.println(S);
Serial.print("DT= ");
Serial.println(D);
delayMicroseconds(1000);
digitalWrite(CLK, LOW);
Serial.print("SW= ");
S = digitalRead(SW);
Serial.print("DT= ");
D = digitalRead(DT);
Serial.println(S);
Serial.println(D);
delayMicroseconds(1000);
delay(1000);
}

115700? Looks funny.

Did you intend 115200?

Yes, you are right! It shall be 115200.

I just made a "raw" program fast, (mybe to fast?) to test and try to find out how it's working.

Thank you for information. I now know why my program in principle not is working, since reading about rotary encounters.

This thread can be closed!

Problem solved!

The gadget is named KY-040 Rotary Encoder.

I found a test program for it and it's working well.