Advertisement
pleasedontcode

"Temperature Reader" rev_02

Mar 6th, 2024
73
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: "Temperature Reader"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-06 07:09:39
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* turn on the led when it work */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /********* User code review feedback **********
  25. #### Feedback 1 ####
  26. - line 26 doesn't work
  27. ********* User code review feedback **********/
  28.  
  29. /****** DEFINITION OF LIBRARIES *****/
  30. #include <Wire.h>
  31. #include <Adafruit_MLX90614.h>
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36.  
  37. /***** DEFINITION OF I2C PINS *****/
  38. const uint8_t but_GY_906_I2C_PIN_SDA_A4 = A4;
  39. const uint8_t but_GY_906_I2C_PIN_SCL_A5 = A5;
  40. const uint8_t but_GY_906_I2C_SLAVE_ADDRESS = 90;
  41.  
  42. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  43. Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  44.  
  45. /****** SYSTEM REQUIREMENTS *****/
  46. /****** SYSTEM REQUIREMENT 1 *****/
  47. const uint8_t ledPin = 13;
  48.  
  49. void setup(void)
  50. {
  51.     // put your setup code here, to run once:
  52.     pinMode(ledPin, OUTPUT);  // Set the LED pin as output
  53.  
  54.     Serial.begin(9600);
  55.     while (!Serial);
  56.  
  57.     Serial.println("Adafruit MLX90614 test");
  58.  
  59.     Wire.begin();
  60.  
  61.     if (!mlx.begin(but_GY_906_I2C_SLAVE_ADDRESS)) {
  62.         Serial.println("Error connecting to MLX sensor. Check wiring.");
  63.         while (1);
  64.     }
  65.  
  66.     Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
  67.     Serial.println("================================================");
  68. }
  69.  
  70. void loop(void)
  71. {
  72.     // put your main code here, to run repeatedly:
  73.     digitalWrite(ledPin, HIGH);   // Turn on the LED
  74.  
  75.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC());
  76.     Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  77.     Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF());
  78.     Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");
  79.  
  80.     digitalWrite(ledPin, LOW);   // Turn off the LED
  81.  
  82.     Serial.println();
  83.     delay(500);
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement