hello I'm trying to add push buttons 5 of them each button is number 1,2,3 for button one 4,5,6 for button 2 789 for button 3 0 for button 4 and send text for button 5. so if i put button 1 i get number 1 if i push it two times i get 1 and 2 for the first button so if i hit the send button it sends number 12 in chat right now i can only send it in serial monitor i have no clue how to do that for the push buttons with this chat i really need help code is below can someone please help me?
#include<SPI.h>
#include"nRf24L01.h"
#include"RF24.h"
//#include"printf.h"
#
RF24 radio(9, 10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
bool go_to_tx_mode = false;
char input[32] = "";
#define PIN_SCE 7 //Pin 3 on LCD
#define PIN_RESET 6 //Pin 4 on LCD
#define PIN_DC 5 //Pin 5 on LCD
#define PIN_SDIN 4 //Pin 6 on LCD
#define PIN_SCLK 3 //Pin 7 on LCD
//The DC pin tells the LCD if we are sending a command or data
#define LCD_COMMAND 0
#define LCD_DATA 1
//You may find a different size screen, but this one is 84 by 48 pixels
#define LCD_X 84
#define LCD_Y 48
//This table contains the hex values that represent pixels
//for a font that is 5 pixels wide and 8 pixels high
void setup() {
LCDInit(); //Init the LCD
Serial.begin(57600);
// printf_begin();
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
radio.startListening();
radio.printDetails();
// put your setup code here, to run once:
}
void loop() {
gotoXY(0,4);
LCDString("------------");
gotoXY(0,5);
LCDString("------------");
if (go_to_tx_mode)
{
radio.stopListening();
bool ok = radio.write(input, 32);
if (ok)
{
// printf("ME : %s\n", input);
LCDClear();
gotoXY(0,0);
LCDString( input);
go_to_tx_mode = false;
radio.startListening();
}
else
printf("could not write....\n");
}
if (radio.available())
{
char payload[32] = "";
bool done = false;
while (!done)
{
done = radio.read( payload , 32 );
LCDClear();
gotoXY(0,0);
LCDString( payload);
// printf("HIM : %s\n", payload);
// printf( payload);
}
}
if (Serial.available())
{
int len = Serial.readBytesUntil('\n', input, 31);
input[len] = '\0';
go_to_tx_mode = true;
}
}
void gotoXY(int x, int y) {
LCDWrite(0, 0x80 | x); // Column.
LCDWrite(0, 0x40 | y); // Row. ?
}
//This takes a large array of bits and sends them to the LCD
void LCDBitmap(char my_array[]){
for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++)
LCDWrite(LCD_DATA, my_array[index]);
}
//This function takes in a character, looks it up in the font table/array
//And writes it to the screen
//Each character is 8 bits tall and 5 bits wide. We pad one blank column of
//pixels on each side of the character for readability.
void LCDCharacter(char character) {
LCDWrite(LCD_DATA, 0x00); //Blank vertical line padding
for (int index = 0 ; index < 5 ; index++)
LCDWrite(LCD_DATA, ASCII[character - 0x20][index]);
//0x20 is the ASCII character for Space (' '). The font table starts with this character
LCDWrite(LCD_DATA, 0x00); //Blank vertical line padding
}
//Given a string of characters, one by one is passed to the LCD
void LCDString(char *characters) {
while (*characters)
LCDCharacter(*characters++);
}
//Clears the LCD by writing zeros to the entire screen
void LCDClear(void) {
for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++)
LCDWrite(LCD_DATA, 0x00);
gotoXY(0, 0); //After we clear the display, return to the home position
}
//This sends the magical commands to the PCD8544
void LCDInit(void) {
//Configure control pins
pinMode(PIN_SCE, OUTPUT);
pinMode(PIN_RESET, OUTPUT);
pinMode(PIN_DC, OUTPUT);
pinMode(PIN_SDIN, OUTPUT);
pinMode(PIN_SCLK, OUTPUT);
//Reset the LCD to a known state
digitalWrite(PIN_RESET, LOW);
digitalWrite(PIN_RESET, HIGH);
LCDWrite(LCD_COMMAND, 0x21); //Tell LCD that extended commands follow
LCDWrite(LCD_COMMAND, 0xB1); //Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark
LCDWrite(LCD_COMMAND, 0x04); //Set Temp coefficent
LCDWrite(LCD_COMMAND, 0x14); //LCD bias mode 1:48: Try 0x13 or 0x14
LCDWrite(LCD_COMMAND, 0x20); //We must send 0x20 before modifying the display control mode
LCDWrite(LCD_COMMAND, 0x0C); //Set display control, normal mode. 0x0D for inverse
}
//There are two memory banks in the LCD, data/RAM and commands. This
//function sets the DC pin high or low depending, and then sends
//the data byte
void LCDWrite(byte data_or_command, byte data) {
digitalWrite(PIN_DC, data_or_command); //Tell the LCD that we are writing either to data or a command
//Send the data
digitalWrite(PIN_SCE, LOW);
shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
digitalWrite(PIN_SCE, HIGH);
}
i can not post the ASCII because the forum say i went over the limit of what i can post.