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 Filtering
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-12-15 11:22:04
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* GENERATRE LOW PASS FILTER TECHNIQUE USING ARDUINO */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* generatae the 100 sample using temperatre sensor */
- /* collect in an array use low pass filter formula to */
- /* get the code */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* GENERATE LOW PASS FILTER TECHNIQUE USING ARDUINO */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* GENERATE 100 SAMPLES USING TEMPERATURE SENSOR */
- /* COLLECT IN AN ARRAY AND USE LOW PASS FILTER FORMULA TO */
- /* GET THE FILTERED VALUE */
- /****** END SYSTEM REQUIREMENTS *****/
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t LOW_PASS_PIN_A0 = A0;
- /***** GLOBAL VARIABLES *****/
- const int SAMPLE_SIZE = 100; // Number of samples to collect
- int samples[SAMPLE_SIZE]; // Array to store the collected samples
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(LOW_PASS_PIN_A0, INPUT);
- Serial.begin(9600); // Initialize serial communication
- // Collect samples from temperature sensor
- for (int i = 0; i < SAMPLE_SIZE; i++)
- {
- samples[i] = analogRead(LOW_PASS_PIN_A0);
- delay(10); // Delay between each sample collection
- }
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- // Apply low pass filter to the collected samples
- int filteredValue = 0;
- for (int i = 0; i < SAMPLE_SIZE; i++)
- {
- filteredValue += samples[i];
- }
- filteredValue /= SAMPLE_SIZE;
- Serial.print("Filtered Value: ");
- Serial.println(filteredValue);
- delay(1000); // Delay between each iteration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement