sterretje:
'D' is actually 0D and if you look it up at asciitable.com, it's a carriage return (and not a linefeed). Change your endmarker to '\r' (or 0x0D) and it should work.
YES! I got it working! The program is alive at last!
I have now created this new program that will later be interfaced into my main code.
This new code incorporates a TFT LCD, and the radio module that I am trying to set the frequency.
//Required Libraries
#include "TouchScreen.h" //Screen Library
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include "Wire.h" //Uno to Mega communication library
#include <PS2Keyboard.h> //Keyboard
#include <TEA5767Radio.h>
//TFT Needed Data
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
//Setting up the devices
PS2Keyboard keyboard;
TEA5767Radio radio = TEA5767Radio();
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
//Buffer Variable Stuff
const byte numChars = 32;
char receivedChars[numChars];
boolean newData = false;
//Keyboard Pins
const int DataPin = 18;
const int IRQpin = 19;
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\r';
char rc;
while (keyboard.available() > 0 && newData == false)
{
Serial.println("characters available");
rc = keyboard.read();
Serial.print(rc, HEX);
if (rc != endMarker)
{
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else
{
Serial.println(" endMarker received");
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void setup() {
//Initializing various devices
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
Wire.begin();
Serial.begin(9600);
keyboard.begin(DataPin, IRQpin);
//Setting Up The on screen visuals
tft.fillScreen(BLUE);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print("FM Radio");
tft.setTextSize(1);
tft.println("Enter Station");
tft.println();
}
void loop() {
recvWithEndMarker();
if (newData == true) {
tft.fillScreen(BLUE);
tft.print("You are listening to");
tft.println(receivedChars);
radio.setFrequency(receivedChars[32]);
newData = false;
}
}
However, when I enter the frequency and hit ENTER, the radio does not go to the frequency?
What could be wrong?
I speculate that radio is not accepting the Buffer array as a proper frequency, that can be inputted into the TEA5767 module!
What can I do about this????
Thank you, thank you, thank you for all the help so far!!!
![]()