Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: Temperature Monitor
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-03-06 11:15:35
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* note: Ensure to save sanitizer from running out */
- /* fastly ensuring that the pump operates for only 4 */
- /* seconds after starting, even if the hand remains */
- /* under the sensor. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h>
- #include <Adafruit_MLX90614.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF I2C PINS *****/
- const uint8_t irsensor_GY_906_I2C_PIN_SDA_A4 = A4;
- const uint8_t irsensor_GY_906_I2C_PIN_SCL_A5 = A5;
- const uint8_t irsensor_GY_906_I2C_SLAVE_ADDRESS = 90;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Adafruit_MLX90614 mlx = Adafruit_MLX90614();
- // Variable to track the pump activation time
- unsigned long pumpActivationTime = 0;
- const unsigned long pumpActivationInterval = 4000; // 4 seconds
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(9600);
- while (!Serial);
- Serial.println("Adafruit MLX90614 test");
- Wire.begin();
- if (!mlx.begin(irsensor_GY_906_I2C_SLAVE_ADDRESS)) {
- Serial.println("Error connecting to MLX sensor. Check wiring.");
- while (1);
- }
- Serial.print("Emissivity = "); Serial.println(mlx.readEmissivity());
- Serial.println("================================================");
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- unsigned long currentMillis = millis();
- // Check if the pump activation interval has passed
- if (currentMillis - pumpActivationTime >= pumpActivationInterval)
- {
- pumpActivationTime = currentMillis;
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement