Modify the existing code that will display a status bar (LED displays to act as status bar) if the frequeny increases the status bar increases and vice versa. Frequency starts with 100.
link to circuit and leds
#include<LiquidCrystal.h>
#define e_A 5
#define e_B 6
#define SWITCH 7
intencoderPos = 0;
LiquidCrystallcd(13,12,14,15,16,17);
booleane_ALast = LOW;
void setup()
{
pinMode(e_A, INPUT);
pinMode(e_B, INPUT);
pinMode(SWITCH, INPUT);
digitalWrite(e_A, HIGH);
digitalWrite(e_B, HIGH);
lcd.begin(16,2);
lcd.print("Rotary Encoder");
}
void loop()
{
booleanencoderA = digitalRead(e_A);
if ((e_ALast == HIGH) && (encoderA == LOW))
{
if (digitalRead(e_B) == LOW)
{
encoderPos--; }
else
{
encoderPos++;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("POS:");
lcd.setCursor(5,0);
lcd.print(encoderPos);
intbuzzertone = encoderPos+100;
tone(9,buzzertone,100);
lcd.setCursor(0,1);
lcd.print("FREQ:");
lcd.setCursor(6,1);
lcd.print(buzzertone);
}
e_ALast = encoderA;
}