2 years, 6 months ago.

seriallcd not working? showing error on write command. Please help

I am using tx rx serial lcd.


#include "mbed.h"
//#include "SerialLCD.h"
#include "TextLCD.h"

DigitalOut myled(LED1);
//SoftSerial SoftSerial(PinName p9, PinName NC, const char* name = NULL);
Serial mySerial(NC, p9);
int temp, rpm;
char tempstring[10], rpmstring[10]; // create string arrays

void setup()
  mySerial.baud(9600); // set up serial port for 9600 baud
  wait(500); // wait for display to boot up

  mySerial.write(254); // cursor to beginning of first line

  mySerial.write("RPM:            "); // clear display + legends
  mySerial.write("TEMP:           ");

void loop() 
  temp = rand(1000); // make some fake data
  rpm = rand(10000);

  mySerial.printf(tempstring,"%4d",rpm); // create strings from the numbers
  mySerial.printf(rpmstring,"%4d",temp); // right-justify to 4 spaces

  mySerial.write(254); // cursor to 7th position on first line
  mySerial.write(rpmstring); // write out the RPM value

  mySerial.write(254); // cursor to 7th position on second line

  mySerial.write(tempstring); // write out the TEMP value
  wait(1000); // short delay

int main() {
    while(1) {
        myled = 1;

Jay, which pin on your board is being used for the TX pin for the serial output ? Serial mySerial(NC, p9); cannot use NC for the TX definition

see here for more details: Suggest to comment out all access to the serial port and work on a single serial output line. Move forward after the single line is working correctly.

posted by Sanjiv Bhatia 08 Nov 2016

Error: Function "mbed::Stream::write" (declared at <a href="#" onmousedown="mbed_doc_goto('/mbed_lcdtesterextras/mbed_25aea2a3f4e3/Stream.h', '52'); return false;">/extras/mbed_25aea2a3f4e3/Stream.h:52</a>) is inaccessible in "main.cpp", Line: 16, Col: 13

this error is shown when compiled. Can you explain me please.

posted by jayendra mishra 08 Nov 2016
Comment on this question
Be the first to answer this question.

Assigned to Graham Moore 2 years, 6 months ago.

This means that the question has been accepted and is being worked on.

To post an answer, please log in.