b707
July 18, 2024, 6:22am
2
Is this the same as
#include <Arduino.h>
#include <esp32-hal-timer.h>
// Pin definitions
const int buttonPin = 34; // Pin connected to the button
const int clockPin = 18; // Pin connected to the clock output
// Timer variables
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
volatile bool clockRunning = false;
// Interrupt service routine for the timer
void IRAM_ATTR onTimer() {
digitalWrite(clockPin, !digitalRead(clockPin)); // Toggle clock pin state
}
// Interrupt servi…
and this
#include <Arduino.h>
#include <esp32-hal-timer.h>
// Define the LED pin
const int ledPin = 18;
// Define the button pin
const int buttonPin = 34;
volatile bool button = false;
// Define the timer frequency (10 MHz)
//const int timerFrequency = 10000000;
// Define the timer period (50% duty cycle, 1 Hz)
//const int timerPeriod = timerFrequency / 2;
// Create a timer object
hw_timer_t * timer = NULL;
// Flag to indicate whether the LED is currently blinking
//bool ledBlinking = true;
void IR…
and continuation of this:
#include <Arduino.h>
#include <esp32-hal-timer.h>
hw_timer_t *timer = NULL;
const int ledPin = 2;
void IRAM_ATTR onTimer() {
// Toggle LED state
digitalWrite(ledPin, !digitalRead(ledPin));
}
void setup() {
pinMode(ledPin, OUTPUT);
// Initialize timer 0 with a frequency of 1 Hz
timer = timerBegin(0, 1);
// Attach an ISR function to the timer
timerAttachInterrupt(timer, &onTimer, true);
// Set an alarm to trigger after 1 second
timerAlarmWrite(timer, 1000000, true); // 10…
Why did you still opened a new threads about your problem? Please continue the discussion inside a single topic. Duplicate threads is a violation of the forum rules.