// Define the pins
const int pin1 = 9;
const int pin2 = 10;
// Frequency in Hertz
const float frequency = 2.0;
// Period of the wave in milliseconds
const float period = 1000.0 / frequency;
void setup() {
// Initialize the digital pins as outputs
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
}
void loop() {
// Turn pin1 on and pin2 off
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
// Wait for half the period (one quarter of the sine wave cycle)
delay(period / 2);
// Turn pin1 off and pin2 on
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
// Wait for the other half of the period
delay(period / 2);
}