Advertisement
pleasedontcode

Sensor Integration rev_03

Mar 6th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Sensor Integration
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-06 07:49:53
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on the led when it work */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* i want the alarm get activated when the gaz sensor */
  23.     /* in on */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Wire.h>
  28. #include <Adafruit_MLX90614.h> //https://github.com/adafruit/Adafruit-MLX90614-Library
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t gaz_PIN_D2 = 2;
  36. const uint8_t led_PIN_D13 = 13;
  37.  
  38. /***** DEFINITION OF I2C PINS *****/
  39. const uint8_t but_GY_906_I2C_PIN_SDA_A4 = A4;
  40. const uint8_t but_GY_906_I2C_PIN_SCL_A5 = A5;
  41. const uint8_t but_GY_906_I2C_SLAVE_ADDRESS = 90;
  42.  
  43. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  44. Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  45.  
  46. void setup(void)
  47. {
  48.   // put your setup code here, to run once:
  49.   pinMode(gaz_PIN_D2, INPUT);
  50.   pinMode(led_PIN_D13, OUTPUT);
  51.  
  52.   Serial.begin(9600);
  53.   while (!Serial)
  54.     ;
  55.  
  56.   Serial.println("Adafruit MLX90614 test");
  57.  
  58.   if (!mlx.begin())
  59.   {
  60.     Serial.println("Error connecting to MLX sensor. Check wiring.");
  61.     while (1)
  62.       ;
  63.   };
  64.  
  65.   Serial.print("Emissivity = ");
  66.   Serial.println(mlx.readEmissivity());
  67.   Serial.println("================================================");
  68. }
  69.  
  70. void loop(void)
  71. {
  72.   // put your main code here, to run repeatedly:
  73.  
  74.   // Check if the gas sensor is on
  75.   if (digitalRead(gaz_PIN_D2) == HIGH)
  76.   {
  77.     // Activate the alarm
  78.     digitalWrite(led_PIN_D13, HIGH);
  79.   }
  80.   else
  81.   {
  82.     // Turn off the alarm
  83.     digitalWrite(led_PIN_D13, LOW);
  84.   }
  85.  
  86.   Serial.print("Ambient = ");
  87.   Serial.print(mlx.readAmbientTempC());
  88.   Serial.print("*C\tObject = ");
  89.   Serial.print(mlx.readObjectTempC());
  90.   Serial.println("*C");
  91.   Serial.print("Ambient = ");
  92.   Serial.print(mlx.readAmbientTempF());
  93.   Serial.print("*F\tObject = ");
  94.   Serial.print(mlx.readObjectTempF());
  95.   Serial.println("*F");
  96.  
  97.   Serial.println();
  98.   delay(500);
  99. }
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement