Reducere!
Rotary-Encoder-Module-roboromania-Bucuresti
Rotary-Encoder-Module-roboromania-Schematicpini-Rotary-Encoder-Module-roboromania-pini

Modul encoder rotativ compatibil Arduino (143)

20,00 RON. 18,00 RON.

Modul encoder rotativ compatibil Arduino
Arduino projects.

Categorii: , Etichete: , ,

Modul encoder rotativ compatibil Arduino (143)

Modul encoder rotativ compatibil Arduino

Mişcare arbore 360 grade (rotire)
20 impulsuri
Aceste impulsuri sunt folosite pentru a controla deplasarea unghiulara
incarcare comutator : 10mA / 5VDC
cu moment pe comutator

Rotary-Encoder-Module-roboromania-Bucurestipini-rotary-encoder-module-roboromania-pini2

Și un cod simplu de test Arduino-Encoder :

rotary-encoder-arduino-tutorial-roboromania

// Arduino Rotary Encoder Tutorial
int encoderCLK = 6;
int encoderDT = 7;

volatile int lastEncoded = 0;
volatile long encoderValue = 0;

long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

void setup() {
Serial.begin (9600);

pinMode(encoderCLK, INPUT);
pinMode(encoderDT, INPUT);

digitalWrite(encoderCLK, HIGH); //turn pullup resistor on
digitalWrite(encoderDT, HIGH); //turn pullup resistor on

//call updateEncoder() when any high/low changed seen
//on interrupt 0 (pin 2), or interrupt 1 (pin 3)
attachInterrupt(0, updateEncoder, CHANGE);
attachInterrupt(1, updateEncoder, CHANGE);
}

void loop(){
Serial.println(encoderValue);
delay(10);
}

void updateEncoder(){
int MSB = digitalRead(encoderCLK); //MSB = most significant bit
int LSB = digitalRead(encoderDT); //LSB = least significant bit

int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number
int sum = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue –;

lastEncoded = encoded; //store this value for next time
}

// Arduino Rotary Encoder Tutorial

Arduino projects.

Opinii

Nu există încă recenzii.

Fii primul care scrie un comentariu “Modul encoder rotativ compatibil Arduino (143)”