Go Down

Topic: How to lcd print the individual bits char val (Read 1 time) previous topic - next topic



Oct 11, 2010, 10:51 pm Last Edit: Oct 11, 2010, 10:52 pm by PaulS Reason: 1
You could use the bitRead() function, and construct the char array one bit at a time.

Code: [Select]
byte byteSizeVal = 45;
char byteAsString[10];

for(byte b=7; b>=0; b--)
  byteAsString[b] = bitRead(byteSizeVal, b) + '0';
  byteAsString[b+1] = '\0';


Look at strcpy, strncpy and strlen (standard C functions)
Code: [Select]
char OutBuf[20] ;
itoa(MF,itoaMFBuffer,itoaBase) ;
strcpy(strncpy(OutBuf,"0000000",8-strlen(itoaMFBuffer),itoaMFBuffer) ;

I've written this straight in the editor, so minor syntax/coding errors possible  :) but this should lead you to a possible solution

BTW, Are you or the code putting the space " " between the nibbles?


Oct 11, 2010, 11:30 pm Last Edit: Oct 12, 2010, 03:57 am by markov85 Reason: 1
Ohh this might be disleading
the space between the numbers like 1111 1111 is put by me manually, I mean the display doesn't show those "nibbles", it shows "11111111"(without the nibble), but that's okey I don't want that nibble anyway.

Will try the code tomorrow.

Go Up