10 years, 1 month ago.

Digital outputs and converting code from Arduino

Hi everyone. I am moving an program from the Arduino over to the Mbed and have a question about using digital outputs.

My Arduino code is as follows:

void Display::LCD(const uint8_t LCD_select) { digitalWrite(LCD_select, LOW); SlaveSelect LOW delay(5); SPI.transfer(LCD_RESET); digitalWrite(LCD_select, HIGH); SlaveSelect HIGH delay(5); }

The issue im having is originally I was passing in a value for which digital to use for my SlaveSelect. With the Mbed the digital out is a little harder to work with using the DigitalOut (PinName pin). My question is can the digital output be accessed in a manner similar to the Arduino's digitalWrite(PinNumber, LOW)? Any other suggestions?

4 Answers

10 years, 1 month ago.

It is not intended to be used that way. But while you have to do it a bit different, it normally shouldn't be an issue. You still pass which pin is slaveselect, but now you make it in the constructor a digitalout. See for example: http://mbed.org/users/Sissors/code/S25FL216K/

10 years, 1 month ago.

Hello Rob Crain,

Just create as you noticed, DigitalOut object and then use methods write, read, or operator =. I would like to know how come it's harder to work with DigitalOut class compared to digitalWrite(pin, value) method?

To create another layer compatible with Arduino is not yet implemented, but might be in the future. However, you can create the abstraction above DigitalOut, a new function digitalWrite(pin, value) which would decode which object to use and set the value.

Regards,
0xc0170

5 years, 11 months ago.

I like to play sudoku online with full enjoy and fun. This is the game which we play in newspaper as well as we play free sudoku and you want to play so click on our home page https://sudokuonlineplay.net/ without register and download.

Rob Crain
poster
10 years, 1 month ago.

Eric, Martin thank you both for the reply.

Martin, I believe it's difficult because I have an existing application that I wish to bring over to mbed. The problem i'm having is the application is very large and uses a custom spi library that is based around a class. When I pass the name of the I/O that I wish to use in the function I get a Complier Error 20. It's just going to take me some time getting use to the new methods and adjusting code.

I like to play roblox robux free of cost on internet https://profiles.delphiforums.com/n/pfx/profile.aspx?webtag=dfpprofile000&userId=1891006313 to do full fun with friends and colleagues.

posted by Shravi Verma 08 May 2018