Need help creating MATLAB GUI for Arduino code

Hi, I was wondering if any could help me with implementing a GUI interface in MATLAB for the code below. It should show if the temp and humidity is out of range and display if an object it moved from the ultrasonic sensor and tell if there is movement with the PIR sensor. Thanks.

//Include relevant libaries//
#include <DHT.h>

//DHT11 or DHT22 defined//
#define DHTPIN A0
#define DHTTYPE DHT22

//Trig and Echo difined for ultrasonic//
#define PIN_TRIG 3
#define PIN_ECHO 2

//LEDS  ints//
int LED1 = 7;
int LED2 = 6;
int LED3 = 5;
int LED4 = 4;

//PIR ints//
int sensor = 12;// the pin that the sensor is atteched to
int state = LOW;// by default, no motion detected
int val = 0;// variable to store the sensor status (value)

DHT dht(DHTPIN, DHTTYPE);

//Setup//
void setup() {
  Serial.begin(9600);
  dht.begin();
 pinMode(PIN_TRIG, OUTPUT);
  pinMode(PIN_ECHO, INPUT);
  pinMode(LED4, OUTPUT); // initalize LED as an output
  pinMode(sensor, INPUT);
}

//void loops//
void loop() {
Tempsensor(); 
Dissensor(); 
PIRsensor(); 
}
//Temperature Senosor(DHt11)//
void Tempsensor(){
    // Read Humidity
  float h = dht.readHumidity();
    // Read temperature as Celsius
  float t = dht.readTemperature();
  val = digitalRead(sensor);
   digitalWrite(PIN_TRIG, LOW);
  delayMicroseconds(10);
  digitalWrite(PIN_TRIG, HIGH);
  int duration = pulseIn(PIN_ECHO, HIGH);
  int cm = duration/58;

  Serial.print("Temp:");
  Serial.print(t);
  Serial.print("\t");
  Serial.print("Hum:");
  Serial.print(h);
  Serial.print("\t");
  Serial.print("CM:");
  Serial.print(cm);
Serial.print("\t");
  Serial.print("  Move:");
  Serial.println(val);
 
if (t>= 50 || t<=10){
    digitalWrite(LED1, LOW);
    tone(13,250);
    delay(500);
    tone(13,400);
    delay(500); 
  }
  else if (t>= 10 && t<=50){
    digitalWrite(LED1, HIGH);
  }

if (h>= 50 || h<=10){
    digitalWrite(LED2, LOW);
    tone(13,250);
    delay(500);
    tone(13,400);
    delay(500); 
  }
  else if (h>= 10 && h <=50){
    digitalWrite(LED2, HIGH);
  }
  delay(400);
  }

//Distance Sensor//
  void Dissensor(){
  // Start a new measurement:
  digitalWrite(PIN_TRIG, LOW);
  delayMicroseconds(10);
  digitalWrite(PIN_TRIG, HIGH);
  // Read the result:
  int duration = pulseIn(PIN_ECHO, HIGH);
  int cm = duration/58;

if (cm >= 100 || cm<=50){
  digitalWrite(LED3, LOW);
  delay(200);
  digitalWrite(LED3, HIGH);
}
else { 
  digitalWrite(LED3, HIGH);
}
  }

//PIR Sensor//
  void PIRsensor(){
val = digitalRead(sensor);   // read sensor value
  if (val == HIGH) {           // check if the sensor is HIGH
    digitalWrite(LED4, LOW);   // turn LED ON
    delay(200);                // delay 200 milliseconds 
    digitalWrite(LED4, HIGH); 
    if (state == LOW) {
      state = HIGH;       // update variable state to HIGH
    }
  } 
  else {
      digitalWrite(LED4, HIGH); // turn LED OFF
      delay(200);             // delay 200 milliseconds 
      
      if (state == HIGH){
        state = LOW;       // update variable state to LOW
    }
  }
  }

close the arduino serial monitor
implement a Matlab program to open the serial COM port associated with the Arduino
parse the serial input to extact the temperature, humidity, etc
plot graphs as required

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.