10 years, 10 months ago.

Pins for KL25z?

Hi,

I am new to programming and mbed. I am looking to use the helloworld program with textlcd.. is this compatible with the kl25z board? I know the pins that need to be used, but what in the program needs to be changed to make it work with the kl25z and a 16*2 display?

Thank you

Question relating to:

2 Answers

10 years, 10 months ago.

You just need to set the pins you use for your wiring in the constructor (where you declare the TextLCD object). You can use any pins, no special pins are required.

10 years, 10 months ago.

Thank you Erik. Is this in the main file only or does anything need to be changed in the TextLCD. cpp or TextLCD.h files?

Ie in the hellowirld program, mbed pins (p18, p19 etc) are used, but in the cpp file there is an enumerated constructor with (PinName rs, PinName e... etc). Which should be changed to the kl25z pins?

The constructor is in the main file (or in general wherever you make the object). So in the HelloWorld program it is:

TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7

You need to replace those pins with the ones you use. So on the KL25Z that is PTC12 for example.

posted by Erik - 06 Jan 2014

So nothing needs to be changed in the .cpp and .h files?

posted by Jonathan May 06 Jan 2014

No, in principle that never has to happen. The idea is that they stay the same, and you just use them, you don't have to change them (unless a library has to do something it wasn't originally designed for, but just changing the pins is simply done by changing them in the constructor).

posted by Erik - 06 Jan 2014

Okay- so I've changed the pins in the constructor as below:

TextLCD lcd(PTD0, PTA13, PTC9, PTC8, PTA5, PTA4); rs, e, d0-d3

And connected the power pins to the 5V output and the ground on the microcontroller, but still no output on the display. Do you know what might be wrong?

posted by Jonathan May 07 Jan 2014