Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you do the following... Change your program to decrement encoderPosition every time the push-button is pressed. unsigned long ButtonTimer; long encoderPosition; int A; int

can you do the following...

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

=+ c. a company president deciding whether to open a new factory

Answered: 1 week ago