NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// Define the pins for the PMOS and NMOS
const int PMOS_pin = 9;
const int NMOS_pin = 10;

// Define the pins for the PWM control of the motor speed
const int PWM_pin_A = 3; // Connected to the PMOS gate
const int PWM_pin_B = 5; // Connected to the NMOS gate

// Define the delay for the initial clockwise rotation
const unsigned long delay_time = 5000; // 5 seconds in milliseconds

// Define variables to keep track of the motor state and timing
bool clockwise = true;
unsigned long start_time = 0;

// Function to rotate the motor clockwise
void rotateCW() {
digitalWrite(PMOS_pin, HIGH);
digitalWrite(NMOS_pin, LOW);
analogWrite(PWM_pin_A, 255);
analogWrite(PWM_pin_B, 0);
}

// Function to rotate the motor anticlockwise
void rotateACW() {
digitalWrite(PMOS_pin, LOW);
digitalWrite(NMOS_pin, HIGH);
analogWrite(PWM_pin_A, 0);
analogWrite(PWM_pin_B, 255);
}

void setup() {
// Initialize the pins as outputs
pinMode(PMOS_pin, OUTPUT);
pinMode(NMOS_pin, OUTPUT);
pinMode(PWM_pin_A, OUTPUT);
pinMode(PWM_pin_B, OUTPUT);
}

void loop() {
unsigned long current_time = millis();

// Check if it's time to switch directions
if (current_time - start_time >= delay_time && clockwise) {
// Switch to counterclockwise rotation
clockwise = false;
rotateACW();
}
else {
// Set the motor direction and speed based on the current state
if (clockwise) {
rotateCW();
} else {
rotateACW();
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.