NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

int leftforward = 3;
int leftbackward = 9;
int rightforward = 11;
int rightbackward = 10;
int var = 0;
int repeat_five = 4;
int repeat_three = 2;
int button = A2;
int beep = A3;

void setup()
{
pinMode(leftforward, OUTPUT);
pinMode(leftbackward, OUTPUT);
pinMode(rightforward, OUTPUT);
pinMode(rightbackward, OUTPUT);
pinMode(button, INPUT);
pinMode(beep, OUTPUT);
Serial.begin(9600);
}

void keyscan() // create a function that allows us to detect button press
{
int value; //variable to store button press
value = digitalRead(button); //read value and store from button press

while(!digitalRead(button)) //while button is not pressed
{
//do nothing
}

while(digitalRead(button)) //while the button is pressed
{
value = digitalRead(button);

if(value == HIGH)
{
digitalWrite(beep, HIGH);

while(!digitalRead(button))
digitalWrite(beep, LOW);

}
}
}
void forward(int time)
{
digitalWrite(leftforward, HIGH);
digitalWrite(rightforward, HIGH);

analogWrite(leftforward, 150);
analogWrite(rightforward, 150);
delay(time);
Serial.println("Doing forward");
}

void reverse(int time)
{
digitalWrite(leftbackward, HIGH);
digitalWrite(rightbackward, HIGH);

analogWrite(leftbackward, 150);
analogWrite(rightbackward, 150);
delay(time);
Serial.println("Doing reverse");
}

void emergency_stop(int time)
{
digitalWrite(leftbackward, LOW);
digitalWrite(rightbackward, LOW);
digitalWrite(rightforward, LOW);
digitalWrite(leftforward, LOW);

analogWrite(leftbackward, 0);
analogWrite(rightbackward, 0);
analogWrite(rightforward, 0);
analogWrite(leftforward, 0);
delay(time);
Serial.println("Doing emergency_stop");
}

void forward_right(int time)
{
digitalWrite(leftforward, HIGH);
analogWrite(leftforward, 150);

digitalWrite(rightforward, LOW);
analogWrite(rightbackward, 0);

digitalWrite(leftbackward, LOW);
analogWrite(leftbackward, 0);

digitalWrite(rightbackward, LOW);
analogWrite(rightbackward, 0);
delay(time);
Serial.println("Doing forward_right");
}


void forward_left(int time)
{
digitalWrite(leftforward, LOW);
analogWrite(leftforward, 0);

digitalWrite(rightforward, HIGH);
analogWrite(rightbackward, 150);

digitalWrite(leftbackward, LOW);
analogWrite(leftbackward, 0);

digitalWrite(rightbackward, LOW);
analogWrite(rightbackward, 0);
delay(time);
Serial.println("Doing forward_left");
}



void spin_right(int time)
{
digitalWrite(leftforward, HIGH);
analogWrite(leftforward, 150);

digitalWrite(rightforward, LOW);
analogWrite(rightbackward, 0);

digitalWrite(leftbackward, HIGH);
analogWrite(leftbackward, 0);

digitalWrite(rightbackward, HIGH);
analogWrite(rightbackward, 150);
delay(time);
Serial.println("Doing spin_right");
}


void spin_left(int time)

{
digitalWrite(leftforward, LOW);
analogWrite(leftforward, 0);

digitalWrite(rightforward, HIGH);
analogWrite(rightbackward, 150);

digitalWrite(leftbackward, HIGH);
analogWrite(leftbackward, 150);

digitalWrite(rightbackward, LOW);
analogWrite(rightbackward, 0);
delay(time);
Serial.println("Doing spin_left");
}

void loop()
{
keyscan();
advance(1000);

}

void loop()
{

while (var <= 1)

{


var += 1;
forward(1000);
emergency_stop(5000);
reverse(1000);

while (repeat_five <= 4)
{
repeat_five += 1;
forward(500);
}
while (repeat_five <= 4)
{
repeat_five += 1;
reverse(500);
}
while (repeat_five <= 4)
{
repeat_five += 1;
spin_left(1000);
}
while (repeat_five <= 4)
{
repeat_five += 1;
spin_right(1000);
}
while (repeat_three <= 2)
{
repeat_three += 1;
forward_right(1000);
}
while (repeat_three <= 2)
{
repeat_three += 1;
forward_left(1000);
}
Serial.println("Complete a track in 's'");
while (repeat_three <= 2)
{
repeat_three += 1;
spin_left(1000);
}
while(repeat_three <= 2)
{
repeat_three += 1;
spin_right(1000);
}

Serial.println("STOP");


}
emergency_stop(1);
}





     
 
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.