micromouseonline / basicencoder Goto Github PK
View Code? Open in Web Editor NEWBasicEncoder counts pulses from simple rotary control knobs
License: Apache License 2.0
BasicEncoder counts pulses from simple rotary control knobs
License: Apache License 2.0
This repository's README contains the following code snippet:
void loop() {
int encoder_change = encoder.get_change();
if (encoder_change) {
Serial.println(encoder.get_change());
}
}
As pointed out within the same readme, the Serial.println() command will always print a 0 here, because the first call to encoder.get_change() has reset the input counter.
The correct call would be "Serial.println(encoder_change);". Could you please correct this?
Typo?
m_previous_state - pin_state();
should be
m_previous_state = pin_state();
Hello,
first of all thank you for the library.
I just saw the code, and there are some calls to noInterrupts()
.
According to the docs, after a call to noInterrupts()
, interrupts()
must be called for interrupts to be enabled again.
Is it intentional that you leave out the calls to interrupts()
or is it an error?
I want to have two encoders in one script. I assumed it would work like this:
#include <Arduino.h>
#include <BasicEncoder.h>
#include <TimerOne.h>
BasicEncoder encoder(8, 9);
BasicEncoder encoder2(10, 11);
void timer_service() {
encoder.service();
encoder2.service();
}
void setup() {
Serial.begin(230400);
Serial.println("Starting..");
Timer1.initialize(1000);
Timer1.attachInterrupt(timer_service);
}
void loop() {
int encoder_change = encoder.get_change();
if (encoder_change) {
Serial.print("Encoder 1: "); Serial.println(encoder.get_count());
}
int encoder2_change = encoder2.get_change();
if (encoder2_change) {
Serial.print("Encoder 2: "); Serial.println(encoder2.get_count());
}
}
However, when I use this code, both values will change when I turn any of the rotary-encoders, and sometimes they enter a feedback-loop where both of the values will change (equally) endlessly.
I am really bad at Arduino/C, so am I doing something obvious wrong, or is the error somewhere else than on my side here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.