Go Down

Topic: Digital potentiometer (Read 138 times) previous topic - next topic

MvG

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!" :-)

stevieb

#1
Sep 20, 2019, 05:37 pm Last Edit: Sep 20, 2019, 05:46 pm by stevieb
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.

MvG

Exactly!

I been "labing" with it all evening! :-)

MvG

#3
Sep 20, 2019, 09:09 pm Last Edit: Sep 21, 2019, 12:50 pm by MvG
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);
 }

CrossRoads

115700?  Looks funny.

Did you intend 115200?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

MvG

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.

MvG

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!

MvG

Problem solved!

The gadget is named KY-040 Rotary Encoder.

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


Go Up