Yeah it's the 1014D.
I broke down to 1 sig in. The other worked fine.
This is the whole test. Gnd, pin2, pin3, usb power.
I have no jumpers.....?
Asked ai controllini for the code.
The pins are soldered. I need them on top for final installation.
#define OUTPUT_PIN 3
volatile unsigned long lastRisingEdgeTime = 0;
volatile unsigned long period = 0;
void setup() {
pinMode(INPUT_PIN, INPUT);
pinMode(OUTPUT_PIN, OUTPUT);
// Attach an interrupt to the rising edge on the input pin
attachInterrupt(digitalPinToInterrupt(INPUT_PIN), measureFrequency, RISING);
// Set up Timer1 for the output signal
setupTimer1();
}
void loop() {
// Continuously update the output signal based on the measured input frequency
if (period > 0) {
// Calculate the half period for the output frequency, which is twice the input frequency
unsigned long halfPeriod = period / 4; // Divide by 4 to get half period of the doubled frequency
// Generate the output signal
digitalWrite(OUTPUT_PIN, HIGH);
delayMicroseconds(halfPeriod); // Wait for half period
digitalWrite(OUTPUT_PIN, LOW);
delayMicroseconds(halfPeriod); // Wait for half period
}
}
void measureFrequency() {
// Measure the period of the input signal
unsigned long currentTime = micros();
period = currentTime - lastRisingEdgeTime;
lastRisingEdgeTime = currentTime;
}
void setupTimer1() {
// Configure Timer1 for PWM output to achieve approximately 4V on pin 3
// Assuming Arduino operates at 5V and uses a 16MHz clock
TCCR1A = _BV(COM1A1) | _BV(WGM11); // Enable PWM on pin 3 and set mode 10 (phase correct PWM)
TCCR1B = _BV(WGM13) | _BV(CS10); // No prescaling
ICR1 = 40000; // Set top value for a 50% duty cycle at a base frequency, adjust as needed
OCR1A = 32000; // Set duty cycle to 80% to achieve approximately 4V (0.8 * 5V)
}
