Hello,
I am doing preparations for my new project. This involves some basic C knowledge.....
I have the following test code:
#include <string.h>
#include <stdlib.h>
//constants
const byte IputMaxLength = 30 + 1 + 1 + 1;//30 plus header plus footer plus terminating zero
const char Header = '~';
const char Footer = '#';
const char BtnU[] = "ButtonUp";
const char BtnD[] = "ButtonDown";
const char BtnL[] = "ButtonLefr";
const char BtnR[] = "ButtonRight";
char StringIn[IputMaxLength] = {
'\0'};
int ledPin = 13; // LED connected to digital pin 13
void setup(){
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
}
void loop(){
SerialRead();
}
void SerialRead(){
// See if there's incoming serial data:
if(Serial.available() > 0) {
getIncomingChars();
}
Serial.println(StringIn);
}
void getIncomingChars() {
// read the incoming data as a char:
char CharIn = Serial.read();
if ((strlen(StringIn)) < IputMaxLength) {
strcat(StringIn, CharIn)
}
}
I am getting this error message:
In function 'void getIncomingChars()':
error: invalid conversion from 'char' to 'const char*'
What am I doing wrong?
Thanks in advance!