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: Prime Finder
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-12-08 15:27:05
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Generate a Graph of the water flow and the water */
- /* pressure. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <WiFiProvisioner.h> //https://github.com/SanteriLindfors/WiFiProvisioner
- #include <FlowSensor.h> //https://github.com/hafidhh/FlowSensor-Arduino
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t esp32_YF-B1_OUT_PIN_D13 = 13;
- const uint8_t esp32_YF-S201_OUT_PIN_D4 = 4;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- unsigned long startTime;
- unsigned long duration = 30000; // 30 seconds
- unsigned long currentNumber = 2;
- unsigned long maxPrime = 2;
- bool isPrime(unsigned long n) {
- if (n < 2) return false;
- if (n % 2 == 0 && n != 2) return false;
- for (unsigned long i = 3; i * i <= n; i += 2) {
- if (n % i == 0) return false;
- }
- return true;
- }
- void setup() {
- Serial.begin(115200);
- startTime = millis();
- pinMode(esp32_YF-B1_OUT_PIN_D13, INPUT);
- pinMode(esp32_YF-S201_OUT_PIN_D4, INPUT);
- }
- void loop() {
- if (millis() - startTime < duration) {
- if (isPrime(currentNumber)) {
- maxPrime = currentNumber;
- }
- currentNumber++;
- } else {
- Serial.print("Highest prime found in 30 seconds: ");
- Serial.println(maxPrime);
- while (true) {} // Stop the program
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment