Code Pal Result

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

// Function to control a simple windshield wiper

void windshieldWiper() {
// Define the pin numbers for the wiper motor control
const int motorPin1 = 3;
const int motorPin2 = 4;

// Set the motor pins as output


pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);

// Move the wiper back and forth 5 times


for (int i = 0; i < 5; i++) {
// Move the wiper in one direction
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
delay(1000); // Delay for 1 second

// Stop the wiper


digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
delay(1000); // Delay for 1 second

// Move the wiper in the opposite direction


digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
delay(1000); // Delay for 1 second

// Stop the wiper


digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
delay(1000); // Delay for 1 second
}
}

You might also like