This is what I have so far. I know it's ugly.

My question is why the outgoing serial control portion at the top does not work after adding in the bottom portion that deals with the LCD. If I comment out the :
while (Serial.available() <20);
through the...
lcd.print(freqLine);
Button and volume controls will then transmit their corresponding codes appropriately.
// these constants won't change:
const int sensorMin = 0; // volume minimum
const int sensorMax = 1000; // volume maximum orig setting 600 // include the library code:
#include "Wire.h"
#include "LiquidCrystal.h" // initialize the library with the numbers of the interface pins LiquidCrystal lcd(0);
#define INPIN1 2 //Arrow up button
#define INPIN2 3 //Arrow down button
int state1 = HIGH;
int state2 = HIGH;
int previousvolume = 0;
int incomingByte = 0;
char freqLine[10];
LiquidCrystal lcd(0);
void setup() {
lcd.begin(20, 4);
Serial.begin(9600);
UCSR0C = UCSR0C | B00111000; // modded to change to odd parity so it matches the Micom standard of 8-odd-1
pinMode(INPIN1, INPUT); //arrow up
pinMode(INPIN2, INPUT); //arrow down
}
void loop() {
// read the volume pot
int sensorReading = analogRead(A0); // map the sensor range to a range of eight options across the volume range:
int range = map(sensorReading, sensorMin, sensorMax, 0, 15);
int volume = range;
//buttonState = digitalRead(buttonPin); // read arrow up button state
delay(10); // debounces switches
int val1 = digitalRead(INPIN1);
int val2 = digitalRead(INPIN2);
{
if (val1 == HIGH)
{
byte UPBUTTON[10] = {
0x24,0x05,0x18,0x36,0xFE,0x7B,0xEF,0x01,0xE0,0x03 }; // up button command
Serial.write(UPBUTTON, 10); // will write the array of bytes to the serial port in raw hex form (length 10)
delay(20);
byte RELEASEBUTTON[10] = {
0x24,0x05,0x18,0x36,0xFF,0x7B,0xEF,0x01,0xE1,0x03 }; // release button command
Serial.write(RELEASEBUTTON, 10); // will write the array of bytes to the serial port in raw hex form (length 10)
delay(50);
}
if (val2 == HIGH)
{
byte DWNBUTTON[10] = {
0x24,0x05,0x18,0x36,0xDF,0x7B,0xEF,0x01,0xC1,0x03 } // up button command
;
Serial.write(DWNBUTTON, 10); // will write the array of bytes to the serial port in raw hex form (length 10)
delay(20);
byte RELEASEBUTTON[10] = {
0x24,0x05,0x18,0x36,0xFF,0x7B,0xEF,0x01,0xE1,0x03 } // release button command
;
Serial.write(RELEASEBUTTON, 10); // will write the array of bytes to the serial port in raw hex form (length 10)
delay(50);
}
}
// Volume control section starts below
if (previousvolume != range){
switch (range) {
case 0: // lowest volume level (muted)
{
byte vol0[8] = {
0x24,0x03,0x18,0x2B,0x00,0x00,0x6A,0x03 } // volume level 0 in hex
;
Serial.write(vol0, 8);
previousvolume = 0;
}
break;
case 1: // 5
{
byte vol10[8] = {
0x24,0x03,0x18,0x2B,0x05,0x00,0x6F,0x03 } // volume level 05 in hex
;
Serial.write(vol10, 8);
previousvolume = 1;
}
break;
case 2:
// 6
{
byte vol5[8] = {
0x24,0x03,0x18,0x2B,0x06,0x00,0x70,0x03 } // volume level 06 in hex
;
Serial.write(vol5, 8);
previousvolume = 2;
}
break;
case 3: // 7
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x07,0x00,0x71,0x03 } // volume level 07 in hex
;
Serial.write(vol20, 8);
previousvolume = range;
}
break;
case 4: // 8
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x08,0x00,0x72,0x03 } // volume level 08 in hex
;
Serial.write(vol20, 8);
previousvolume = 4;
}
break;
case 5: // 9
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x09,0x00,0x73,0x03 } // volume level 09 in hex
;
Serial.write(vol20, 8);
previousvolume = 5;
}
break;
case 6: // 10
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x10,0x00,0x7A,0x03 } // volume level 10 in hex
;
Serial.write(vol20, 8);
previousvolume = 6;
}
break;
case 7: // 12
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x12,0x00,0x7C,0X03 } // volume level 12 in hex
;
Serial.write(vol20, 8);
previousvolume = 7;
}
break;
case 8: // 14
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x14,0x00,0x7E,0x03 } // volume level 14 in hex
;
Serial.write(vol20, 8);
previousvolume = 8;
}
break;
case 9: // 16
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x16,0x00,0x80,0x03 } // volume level 16 in hex
;
Serial.write(vol20, 8);
previousvolume = 9;
}
break;
case 10: // 18
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x20,0x00,0x8A,0x03 } // volume level 18 in hex
;
Serial.write(vol20, 8);
previousvolume = 10;
}
break;
case 11: // 25
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x25,0x00,0x8F,0x03 } // volume level 25 in hex
;
Serial.write(vol20, 8);
previousvolume = 11;
}
break;
case 12: // 30
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x30,0x00,0x9A,0x03 } // volume level 30 in hex
;
Serial.write(vol20, 8);
previousvolume = 12;
}
break;
case 13: // 40
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x40,0x00,0xAA,0x03 } // volume level 40 in hex
;
Serial.write(vol20, 8);
previousvolume = 13;
}
break;
case 14: // 90
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0x90,0x00,0xFA,0x03 } // volume level 90 in hex
;
Serial.write(vol20, 8);
previousvolume = 14;
}
break;
case 15: // 100
{
byte vol20[8] = {
0x24,0x03,0x18,0x2B,0xB0,0x00,0x1A,0x03 } // volume level B0 in hex as FF is ridiculous!
;
Serial.write(vol20, 8);
previousvolume = 15;
}
break;
}
}
char buffer[20];
if (Serial.available() <20);
{
// Do nothing
}
while (Serial.available() <20);
int i;
for (i=0;i<20;i++)
{
buffer[i] = Serial.read();
buffer[i+1] = '\0';
}
char freqArray[10];
for(int i=7, j=0; i<=17; i++, j++)
{
lcd.setCursor(0, 1);
freqLine[j] = buffer[i];
freqLine[j+1] = '\0'; // Keep NULL terminated
}
lcd.print(freqLine);
}
Thanks again.