Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change your program to decrement encoderPosition every time the push-button is pressed. unsigned long ButtonTimer; long encoderPosition; int A; int B; #include LiquidCrystal LcdDriver(11, 9,

Change your program to decrement encoderPosition every time the push-button is pressed.

unsigned long ButtonTimer;

long encoderPosition;

int A;

int B;

#include

LiquidCrystal LcdDriver(11, 9, 5, 6, 7, 8 );

void MonitorA()

{

if (A == B) {

encoderPosition++;

}

else

{

encoderPosition--;

}

}

void MonitorB() {

if (A == B)

{

encoderPosition--;

}

else

{

encoderPosition++;

}

}

//SetUP

void setup() {

LcdDriver.clear();

LcdDriver.begin(16, 2);

LcdDriver.setCursor(0, 0);

ButtonTimer = millis();

pinMode(2, INPUT);

pinMode(3, INPUT);

attachInterrupt ( digitalPinToInterrupt(2), MonitorA , CHANGE);

attachInterrupt (digitalPinToInterrupt(3), MonitorB , CHANGE);

}

//Loop

void loop() {

A = digitalRead(2);

B = digitalRead(3);

if (millis() - ButtonTimer >= 100) {

LcdDriver.clear();

LcdDriver.print(encoderPosition);

ButtonTimer += 100;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions

Question

What is java code

Answered: 1 week ago

Question

=+ What are the information and consultation requirements?

Answered: 1 week ago

Question

=+ Should the MNE belong (why, why not)?

Answered: 1 week ago