CCCPaste

"Sensor Integration" rev_04

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: "Sensor Integration"
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-03-06 07:52:08

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* turn on the led when it work */
/****** SYSTEM REQUIREMENT 2 *****/
	/* i want the alarm get activated when the gaz sensor */
	/* in on */
/****** END SYSTEM REQUIREMENTS *****/


/********* User code review feedback **********
#### Feedback 1 ####
- Adafruit_MLX90614.h: No such file or directory
********* User code review feedback **********/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Turn on the LED when it works */
/****** SYSTEM REQUIREMENT 2 *****/
/* Activate the alarm when the gas sensor is on */
/****** END SYSTEM REQUIREMENTS *****/

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t gas_SENSOR_PIN_D2 = 2;
const uint8_t led_PIN_D13 = 13;

/***** DEFINITION OF I2C PINS *****/
const uint8_t mlx_I2C_PIN_SDA_A4 = A4;
const uint8_t mlx_I2C_PIN_SCL_A5 = A5;
const uint8_t mlx_I2C_SLAVE_ADDRESS = 0x5A; // Default I2C address of MLX90614

/****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup(void)
{
  pinMode(gas_SENSOR_PIN_D2, INPUT);
  pinMode(led_PIN_D13, OUTPUT);

  Serial.begin(9600);
  while (!Serial)
    ;

  Serial.println("Adafruit MLX90614 test");

  if (!mlx.begin(mlx_I2C_SLAVE_ADDRESS))
  {
    Serial.println("Error connecting to MLX90614 sensor. Check wiring.");
    while (1)
      ;
  }

  Serial.print("Emissivity = ");
  Serial.println(mlx.readEmissivity());
  Serial.println("================================================");
}

void loop(void)
{
  if (digitalRead(gas_SENSOR_PIN_D2) == HIGH)
  {
    digitalWrite(led_PIN_D13, HIGH); // Activate the alarm LED
  }
  else
  {
    digitalWrite(led_PIN_D13, LOW); // Turn off the alarm LED
  }

  Serial.print("Ambient = ");
  Serial.print(mlx.readAmbientTempC());
  Serial.print("*C\tObject = ");
  Serial.print(mlx.readObjectTempC());
  Serial.println("*C");
  Serial.print("Ambient = ");
  Serial.print(mlx.readAmbientTempF());
  Serial.print("*F\tObject = ");
  Serial.print(mlx.readObjectTempF());
  Serial.println("*F");

  Serial.println();
  delay(500);
}