Hi to all,
I’ve experienced a very strange problem with printing out a variable via serial com.
In the following code you can see a char data type called “ch” which is definitely not empty,
but the Serial.println(ch); command print out nothing, while the rest print out the correct values
including the char array members . Does anyone had the same problem ever?
Thanks for your help in advance!
cheers, Krisztian
#include <string.h>
const char button = 22;
float offset;
String offsetString;
char chArray[14]={"this is a test"}, ch = 0;
void setup() {
Serial.begin(9600);
pinMode(button, INPUT);
}
void loop() {
if(!digitalRead(button)){
while(!digitalRead(button));
ch++;
if(ch > 10) ch = 10;
offset = ch * 0.5;
offsetString = String(offset,1);
for(int i=0; i<15; i++){
Serial.print(chArray[i]);
}
Serial.println();
Serial.println(offsetString);
Serial.println(ch);
}
}