// QueueHandle_t exampleQueue;
// #define BUTTON_PIN 14 // Define the button pin
// #define LED_PIN 12
// void setup() {
//   // put your setup code here, to run once:
//   Serial.begin(115200);
//   Serial.println("Hello, ESP32!");
//   pinMode(LED_PIN, OUTPUT);

//   exampleQueue = xQueueCreate(10, sizeof(int)); // Create a queue 10 int 
//   if (exampleQueue == NULL) { 
//     Serial.println("Error creating the queue");
//   }
//   // xTaskCreate(producerTask, "producerTask", 1000, NULL, 1, NULL);
//   // xTaskCreate(consumerTask, "consumerTask", 1000, NULL, 2, NULL);
//   xTaskCreate(buttonTask, "Button Monitor Task", 2048, NULL, 1, NULL); // Create the button monitoring task
// }

// void producerTask(void *parameter) {
//    int sendValue = 0; 
//    while (1) {
//      if (xQueueSend(exampleQueue, &sendValue, portMAX_DELAY) == pdPASS) {
//        Serial.print("Item sent: ");
//         Serial.println(sendValue);
//          sendValue++; // Increment the value to send next time
//     } 
//     vTaskDelay(pdMS_TO_TICKS(1000)); // Delay for a period (e.g., 1000 ms)
//    }
// }

// void consumerTask(void *parameter) { 
//   int receivedValue = 0; while (1) { 
//     if (xQueueReceive(exampleQueue, &receivedValue, portMAX_DELAY) == pdTRUE) { 
//       Serial.print("Item received: "); 
//       Serial.println(receivedValue); 
//     } 
//   } 
// }

// void buttonTask(void *parameter) {
//    bool lastButtonState = HIGH; // Assume button is unpressed initially 
//    pinMode(BUTTON_PIN, INPUT_PULLUP); // Set the button pin as input with pull-up 
//    while (1) { 
//     bool currentButtonState = digitalRead(BUTTON_PIN); // Detect falling edge (button press) 
//     if (lastButtonState == HIGH && currentButtonState == LOW) { 
//       vTaskDelay(pdMS_TO_TICKS(50)); // Debounce delay 
//       Serial.println("HEY NOW"); // Print message on button press 
//       } 
//       lastButtonState = currentButtonState; 
//       vTaskDelay(pdMS_TO_TICKS(10)); // Short delay to mitigate switch bounce 
//     } 
//   }

// void loop() {
//   // put your main code here, to run repeatedly:
//   delay(10); // this speeds up the simulation
//   // digitalWrite(LED_PIN, HIGH);
// }
$abcdeabcde151015202530fghijfghij
Loading
esp32-devkit-c-v4