{"id":671,"date":"2015-11-19T18:14:05","date_gmt":"2015-11-19T15:14:05","guid":{"rendered":"http:\/\/arduinoshop.ro\/index.php\/produs\/modul-encoder-rotativ-arduino\/"},"modified":"2025-08-12T10:53:26","modified_gmt":"2025-08-12T07:53:26","slug":"modul-encoder-rotativ-arduino","status":"publish","type":"product","link":"https:\/\/roboromania.ro\/?product=modul-encoder-rotativ-arduino","title":{"rendered":"Modul encoder rotativ compatibil Arduino (143)"},"content":{"rendered":"<p>Modul encoder rotativ compatibil Arduino<\/p>\n<p>Mi\u015fcare arbore 360 grade (rotire)<br \/>\n20 impulsuri<br \/>\nAceste impulsuri sunt folosite pentru a controla deplasarea unghiulara<br \/>\nincarcare comutator : 10mA \/ 5VDC<br \/>\ncu moment pe comutator<\/p>\n<p><a href=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Module-roboromania-Bucuresti.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-819\" src=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Module-roboromania-Bucuresti.jpg\" alt=\"Rotary-Encoder-Module-roboromania-Bucuresti\" width=\"200\" height=\"200\" srcset=\"https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Module-roboromania-Bucuresti.jpg 200w, https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Module-roboromania-Bucuresti-150x150.jpg 150w, https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Module-roboromania-Bucuresti-180x180.jpg 180w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><a href=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/pini-Rotary-Encoder-Module-roboromania-pini2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3397\" src=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/pini-Rotary-Encoder-Module-roboromania-pini2-300x189.jpg\" alt=\"pini-rotary-encoder-module-roboromania-pini2\" width=\"300\" height=\"189\" srcset=\"https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/pini-Rotary-Encoder-Module-roboromania-pini2-300x189.jpg 300w, https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/pini-Rotary-Encoder-Module-roboromania-pini2.jpg 590w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u0218i un cod simplu de test Arduino-Encoder :<\/p>\n<p><a href=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Arduino-Tutorial-roboromania.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3398\" src=\"http:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Arduino-Tutorial-roboromania-216x300.jpg\" alt=\"rotary-encoder-arduino-tutorial-roboromania\" width=\"159\" height=\"221\" srcset=\"https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Arduino-Tutorial-roboromania-216x300.jpg 216w, https:\/\/roboromania.ro\/wp-content\/uploads\/2015\/11\/Rotary-Encoder-Arduino-Tutorial-roboromania.jpg 230w\" sizes=\"auto, (max-width: 159px) 100vw, 159px\" \/><\/a><\/p>\n<p><span style=\"color: #0000ff;\">\/\/ Arduino Rotary Encoder Tutorial<\/span><br \/>\n<span style=\"color: #0000ff;\">int encoderCLK = 6;<\/span><br \/>\n<span style=\"color: #0000ff;\">int encoderDT = 7;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">volatile int lastEncoded = 0;<\/span><br \/>\n<span style=\"color: #0000ff;\">volatile long encoderValue = 0;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">long lastencoderValue = 0;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">int lastMSB = 0;<\/span><br \/>\n<span style=\"color: #0000ff;\">int lastLSB = 0;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">void setup() {<\/span><br \/>\n<span style=\"color: #0000ff;\"> Serial.begin (9600);<\/span><\/p>\n<p><span style=\"color: #0000ff;\">pinMode(encoderCLK, INPUT); <\/span><br \/>\n<span style=\"color: #0000ff;\"> pinMode(encoderDT, INPUT);<\/span><\/p>\n<p><span style=\"color: #0000ff;\">digitalWrite(encoderCLK, HIGH); \/\/turn pullup resistor on<\/span><br \/>\n<span style=\"color: #0000ff;\"> digitalWrite(encoderDT, HIGH); \/\/turn pullup resistor on<\/span><\/p>\n<p><span style=\"color: #0000ff;\">\/\/call updateEncoder() when any high\/low changed seen<\/span><br \/>\n<span style=\"color: #0000ff;\"> \/\/on interrupt 0 (pin 2), or interrupt 1 (pin 3) <\/span><br \/>\n<span style=\"color: #0000ff;\"> attachInterrupt(0, updateEncoder, CHANGE); <\/span><br \/>\n<span style=\"color: #0000ff;\"> attachInterrupt(1, updateEncoder, CHANGE);<\/span><br \/>\n<span style=\"color: #0000ff;\">}<\/span><\/p>\n<p><span style=\"color: #0000ff;\">void loop(){ <\/span><br \/>\n<span style=\"color: #0000ff;\"> Serial.println(encoderValue);<\/span><br \/>\n<span style=\"color: #0000ff;\"> delay(10);<\/span><br \/>\n<span style=\"color: #0000ff;\">}<\/span><\/p>\n<p><span style=\"color: #0000ff;\">void updateEncoder(){<\/span><br \/>\n<span style=\"color: #0000ff;\"> int MSB = digitalRead(encoderCLK); \/\/MSB = most significant bit<\/span><br \/>\n<span style=\"color: #0000ff;\"> int LSB = digitalRead(encoderDT); \/\/LSB = least significant bit<\/span><\/p>\n<p><span style=\"color: #0000ff;\">int encoded = (MSB &lt;&lt; 1) |LSB; \/\/converting the 2 pin value to single number<\/span><br \/>\n<span style=\"color: #0000ff;\"> int sum = (lastEncoded &lt;&lt; 2) | encoded; \/\/adding it to the previous encoded value<\/span><\/p>\n<p><span style=\"color: #0000ff;\">if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;<\/span><br \/>\n<span style=\"color: #0000ff;\"> if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue &#8211;;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">lastEncoded = encoded; \/\/store this value for next time<\/span><br \/>\n<span style=\"color: #0000ff;\">}<\/span><\/p>\n<p><span style=\"color: #0000ff;\">\/\/ Arduino Rotary Encoder Tutorial<\/span><\/p>\n<p>Arduino projects.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Modul encoder rotativ compatibil Arduino<br \/>\nArduino projects.<\/p>\n","protected":false},"featured_media":819,"comment_status":"open","ping_status":"closed","template":"","meta":[],"product_brand":[],"product_cat":[9,15],"product_tag":[7,217,77],"class_list":{"0":"post-671","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-senzori","7":"product_cat-module","8":"product_tag-arduino","9":"product_tag-encoder","10":"product_tag-modul","12":"first","13":"instock","14":"shipping-taxable","15":"purchasable","16":"product-type-simple"},"_links":{"self":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/product\/671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/product"}],"about":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/types\/product"}],"replies":[{"embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=671"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=\/wp\/v2\/media\/819"}],"wp:attachment":[{"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=671"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fproduct_brand&post=671"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fproduct_cat&post=671"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/roboromania.ro\/index.php?rest_route=%2Fwp%2Fv2%2Fproduct_tag&post=671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}