Undefined function 'int' for input arguments of type 'char'

8 vues (au cours des 30 derniers jours)
Alejandro Alarcon
Alejandro Alarcon le 17 Sep 2018
Commenté : Walter Roberson le 17 Sep 2018
I am trying to make a temperature sensor but when i run my code it gives me the error :
Undefined function 'int' for input arguments of type 'char'.
Can somebody help me out please. I read someone asking for this before but nobody gave a clear solution.
My sensor is TMP36 and my code is
int sensorPin = 0;
setup();
void setup()
Serial.begin(9600);
void loop()
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /=1024.0;
Serial.print(voltage);Serial.println(" volts");
float temperatureC= (voltage - 0.5)*100;
Serial.print(temperatureC); Serial.println(" degrees C");
float temperatureF=(TemperatureC*9.0/5.0)+32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(1000);
  1 commentaire
Walter Roberson
Walter Roberson le 17 Sep 2018
MATLAB does not have variable type declarations, and it does not have Serial.* functions. You need to decide if you are programming at the MATLAB level or if you are programming C / C++ code to run on an Arduino or Raspberry Pi.
If you are running at the MATLAB level, then you would need to interface to the device. That could be done through an Arduino, or Raspberry Pi, or could be done by the Data Acquisition Toolbox in connection with a analog to digital convertor device.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Arduino Hardware dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by