Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Reading an Absolute Encoder (Bourns EMS22A) on: August 11, 2014, 02:20:10 pm
Thanks brah - That works perfect!

Seems I just confused with the wiring, since it works now smiley-razz
Thanks for the help anyway.

btw: The ChipSelect pin is realy necessary. Here is my example code in case somebody else wants to tinker with this type of encoders:

Code:
const int PIN_CS = 5;
const int PIN_CLOCK = 6;
const int PIN_DATA = 7;

void setup() {
  Serial.begin(9600);
  pinMode(PIN_CS, OUTPUT);
  pinMode(PIN_CLOCK, OUTPUT);
  pinMode(PIN_DATA, INPUT);

  digitalWrite(PIN_CLOCK, HIGH);
  digitalWrite(PIN_CS, LOW);
}


//byte stream[16];
void loop() {

  digitalWrite(PIN_CS, HIGH);
  digitalWrite(PIN_CS, LOW);
  int pos = 0;
  for (int i=0; i<10; i++) {
    digitalWrite(PIN_CLOCK, LOW);
    digitalWrite(PIN_CLOCK, HIGH);
   
    byte b = digitalRead(PIN_DATA) == HIGH ? 1 : 0;
    pos += b * pow(2, 10-(i+1));
  }
  for (int i=0; i<6; i++) {
    digitalWrite(PIN_CLOCK, LOW);
    digitalWrite(PIN_CLOCK, HIGH);
  }
  digitalWrite(PIN_CLOCK, LOW);
  digitalWrite(PIN_CLOCK, HIGH);
  Serial.println(pos);
}
2  Community / Products and Services / Re: Fetch: Arduino Data Acquisition/Oscilloscope (Alpha2 Release) on: April 30, 2013, 03:41:52 pm
I can't seem to download the zip file - can someone re-up it please. The code looks very useful!
Pages: [1]