hoffmangler,
You and I have been working on similar projects it seems. I started with all the software backend for control of buttons and such - including an LCD to display results of button presses and navigating a menu to send projector commands. Setting up the actual serial connection was next on my list.
I ended up adding a bunch of debug code in my sketch to figure out why my serial interface was not working, I was going the SoftwareSerial approach - but trying to send straight to the projector - not going through a MAX chip ( in the mail now though )
I'll clean up my code again and post it here. I played a lot with buttons and such and have created an interface with a rocker button to navigate a menu on LCD (16x2), a momentary button to 'select' menu options, two toggle swtiches (SPST) one for ON/OFF the other PC/DVD input select. All works great - however haven't implemented the serial thing yet. In my loop() the buttons fire functions which then will do the serial dance.
Will post in the next couple days... tomorrow probably, as I'm still at work now ![]()
here is a snippet of how I manage button pushes - there may be a better way though. I am using Analog pins for the buttons, at first I was using Digital, then something wasn't working so I switched to Analog - results weren't as expected, but then figured out how to make it do what I wanted it to.
I have the projector toggle switch SPST center pin going to +5v, and the other pin going to the Arduino Analog Pin 3. I also have the analog pin 3 jumpered to ground with a 47K resistor. This brings pin 3 to ground when 'power off' but to 5v when 'on'.
int powerSel = 3; // power select switch is ANALOG PIN 3
int statusPw = 0; // holds temp status of powerSel switch
int hiReset = 900; // reset button status when value falls below hiReset - prevents accidental repeat of button input
int powerSelReset = 0; // has button status been reset? 1 yes, 0 no
void power_ON()
{
digitalWrite(ledPin,HIGH); // turns on LED
lcd_clear();
lcd_goto(0);
delay(10);
Serial.println("Power ON "); // currently just set to send debug strings back to my serial monitor
lcd_puts("Power ON "); // prints to LCD panel on control surface, feedback to user
powerSelReset = 0; // resets the powerSelReset to '0' so that the command isn't executed twice
digitalWrite(ledPin,LOW);
}
void setup()
{
lcd_init();
Serial.begin(9600);
menu_show(0);
}
void loop()
{
statusPw = analogRead(powerSel); // reads the input of powerSel
if (statusPw < hiReset)
{
powerSelReset = 1;
}
if (statusPw >= hiThreshold && powerSelReset == 1)
{
digitalWrite(ledPin,HIGH); // turns on LED
power_ON();
digitalWrite(ledPin,LOW); // turns off LED
}
}
I cut and pasted all these snippets from my full sketch, so if somethings don't look like they are doing anything, that is why. I tried to remove most of the erroneous code that doesn't apply to the button example. I'll post a more complete rendition hopefully tomorrow, if not next week.