What's the function of this instruccion: "LPS ps;"

Hello all;

I’m beginning to learn Arduino, and I’m working a matlab S-function block with the code in Matlab, but I found an instruction that I don’t understand the function that it makes, and in which part of the S-function builder I need to put it.

The instruction is:

LPS ps;

And this is the code:

#include <Wire.h>
#include <LPS.h>

LPS ps;

void setup()
{
 Serial.begin(9600);
 Wire.begin();

 if (!ps.init())
 {
   Serial.println("Failed to autodetect pressure sensor!");
   while (1);
 }

 ps.enableDefault();
}

void loop()
{
 float pressure = ps.readPressureMillibars();
 float altitude = ps.pressureToAltitudeMeters(pressure);
 float temperature = ps.readTemperatureC();
 
 Serial.print("p: ");
 Serial.print(pressure);
 Serial.print(" mbar\ta: ");
 Serial.print(altitude);
 Serial.print(" m\tt: ");
 Serial.print(temperature);
 Serial.println(" deg C");

 delay(100);
}

Thanks for your help

Regards

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

The instruction looks like it is associated with the LPS.h library.+ It may start some function within the library. Check the documentation for the library to see what it does.

Tom.... :)

Hi Tom,

Thanks for your answer and sorry for my mistake in the format, I just change the format with your manual.

Regards Alberto

That statement defines a new variable named ps which has a datatype of LPS. LPS is probably a class. So ps will be an instance of that class.

It looks like this lib "lps-arduino" (Arduino library for Pololu LPS25H and LPS331AP boards): https://github.com/pololu/lps-arduino

There is documentation there for the library.

Thanks for all your responses, so I understand that all the instructions that have a ps before like:

ps.readPressureMillibars()

It's calling the function readPressureMillibars() that is in the file LPS.cpp or LPS.h.

But this create another question:

How can I insert this calling to function in a S-function block of matlab??

Thanks