jmartinez508
Member
I am a sys admin who inherited this project and could use a helping hand. This is a simple LCD running on a Teensy 2.0 board and has two push to talk buttons.
I know nothing about programming but managed to pull the RGB colors off of the hardware and am now able to manipulate them in code.
The only thing I need to do now is make the lcd blink another color when the button is pushed. so right now say its blue they hit the button and I want it to turn green just for a second to acknowledge the button was pushed. and that's it lol
Any help or guidance is immensely appreciated and I will owe you beer if you help me.
here is my code!
#include <Bounce.h>
#include <LiquidCrystal.h>
Bounce ptt0 = Bounce(14, 10);
Bounce chanSelect0 = Bounce(13, 10);
LiquidCrystal lcd(12, 11, 23, 22, 8, 7);
int redpin = 4;
int greenpin = 9;
int bluepin = 10;
int pttPressed = 0;
int chanPressed = 0;
int chanNum = 1;
void setup() {
pinMode (redpin, OUTPUT) ;
pinMode (greenpin, OUTPUT) ;
pinMode (bluepin, OUTPUT) ;
pinMode(14, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("Ch 1 - P!");
lcd.setCursor(0, 1);
lcd.print("----------------");
digitalWrite (greenpin, HIGH) ;
}
void loop() {
ptt0.update();
chanSelect0.update();
if (ptt0.fallingEdge() && chanPressed == 0) {
pttPressed = 1;
Keyboard.set_modifier(MODIFIERKEY_SHIFT);
Keyboard.set_key1(KEY_P);
//If the channel == 1 then send P!
if (chanNum == 1) {
Keyboard.set_key2(KEY_1);
}
//If the channel == 2 then send P@
if (chanNum == 2) {
Keyboard.set_key2(KEY_2);
}
//If the channel == 3 then send P#
if (chanNum == 3) {
Keyboard.set_key2(KEY_3);
}
//If the channel == 1 then send P$
if (chanNum == 4) {
Keyboard.set_key2(KEY_4);
}
//If the channel == 5 then send P%
if (chanNum == 5) {
Keyboard.set_key2(KEY_5);
}
lcd.setCursor(0, 1);
lcd.print("....Transmit....");
Keyboard.send_now();
}
if (ptt0.risingEdge() && pttPressed == 1) {
pttPressed = 0;
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.set_key2(0);
lcd.setCursor(0, 1);
lcd.print("----------------");
Keyboard.send_now();
}
if (chanSelect0.fallingEdge() && pttPressed == 0) {
chanPressed = 1;
}
if (chanSelect0.risingEdge() && pttPressed == 0) {
if (chanNum == 5) {
chanNum = 1;
lcd.setCursor(0, 0);
lcd.print("Ch 1 - P!");
} else {
chanNum = chanNum + 1;
if (chanNum == 2) {
lcd.setCursor(0, 0);
lcd.print("Ch 2 - P@");
}
if (chanNum == 3) {
lcd.setCursor(0, 0);
lcd.print("Ch 3 - P#");
}
if (chanNum == 4) {
lcd.setCursor(0, 0);
lcd.print("Ch 4 - P$");
}
}
chanPressed = 0;
}
}
I know nothing about programming but managed to pull the RGB colors off of the hardware and am now able to manipulate them in code.
The only thing I need to do now is make the lcd blink another color when the button is pushed. so right now say its blue they hit the button and I want it to turn green just for a second to acknowledge the button was pushed. and that's it lol
Any help or guidance is immensely appreciated and I will owe you beer if you help me.
here is my code!
#include <Bounce.h>
#include <LiquidCrystal.h>
Bounce ptt0 = Bounce(14, 10);
Bounce chanSelect0 = Bounce(13, 10);
LiquidCrystal lcd(12, 11, 23, 22, 8, 7);
int redpin = 4;
int greenpin = 9;
int bluepin = 10;
int pttPressed = 0;
int chanPressed = 0;
int chanNum = 1;
void setup() {
pinMode (redpin, OUTPUT) ;
pinMode (greenpin, OUTPUT) ;
pinMode (bluepin, OUTPUT) ;
pinMode(14, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.print("Ch 1 - P!");
lcd.setCursor(0, 1);
lcd.print("----------------");
digitalWrite (greenpin, HIGH) ;
}
void loop() {
ptt0.update();
chanSelect0.update();
if (ptt0.fallingEdge() && chanPressed == 0) {
pttPressed = 1;
Keyboard.set_modifier(MODIFIERKEY_SHIFT);
Keyboard.set_key1(KEY_P);
//If the channel == 1 then send P!
if (chanNum == 1) {
Keyboard.set_key2(KEY_1);
}
//If the channel == 2 then send P@
if (chanNum == 2) {
Keyboard.set_key2(KEY_2);
}
//If the channel == 3 then send P#
if (chanNum == 3) {
Keyboard.set_key2(KEY_3);
}
//If the channel == 1 then send P$
if (chanNum == 4) {
Keyboard.set_key2(KEY_4);
}
//If the channel == 5 then send P%
if (chanNum == 5) {
Keyboard.set_key2(KEY_5);
}
lcd.setCursor(0, 1);
lcd.print("....Transmit....");
Keyboard.send_now();
}
if (ptt0.risingEdge() && pttPressed == 1) {
pttPressed = 0;
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.set_key2(0);
lcd.setCursor(0, 1);
lcd.print("----------------");
Keyboard.send_now();
}
if (chanSelect0.fallingEdge() && pttPressed == 0) {
chanPressed = 1;
}
if (chanSelect0.risingEdge() && pttPressed == 0) {
if (chanNum == 5) {
chanNum = 1;
lcd.setCursor(0, 0);
lcd.print("Ch 1 - P!");
} else {
chanNum = chanNum + 1;
if (chanNum == 2) {
lcd.setCursor(0, 0);
lcd.print("Ch 2 - P@");
}
if (chanNum == 3) {
lcd.setCursor(0, 0);
lcd.print("Ch 3 - P#");
}
if (chanNum == 4) {
lcd.setCursor(0, 0);
lcd.print("Ch 4 - P$");
}
}
chanPressed = 0;
}
}