Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo motor1;
- Servo motor2;
- char readString;
- void setup()
- {
- Serial.begin( 9600);
- Serial.print("Code is spinoff by Baraq, original code by Jai Sawnhey");
- Serial.print(" ");
- Serial.print("Please say life if you see this");
- motor1.attach(7);
- motor2.attach(8);
- }
- void loop()
- {
- while ( Serial.available() )
- { // While there is data in the buffer
- delay( 3 );
- char c = Serial.read();
- readString = c;
- }
- Serial.println( readString );
- //right
- /* if ( readString == "p" )
- {
- motor1.attach(7);
- motor1.write(99);
- }
- if ( readString == "s" )
- {
- motor1.attach(7);
- motor1.write(105);
- }
- if ( readString == "r" )
- {
- motor1.detach();
- //motor1.write(100);
- }
- readString="";
- }
- }
- */
- /*
- if ( readString == "l2" )
- {
- motor2.write(80);
- }
- if ( readString == "r2" )
- {
- motor2.write(100);
- }
- if ( readString == "s2" )
- {
- motor2.write(90);
- }
- if ( readString == "l")
- {
- motor1.write(80);
- }
- if ( readString == "l")
- {
- motor1.write(100);
- }
- if ( readString == "s")
- {
- motor1.write(90);
- }
- }
- }
- */
- //motor 2 left
- //motor 1 right
- if ( readString == "s")
- {
- motor1.write(90);
- motor2.write(90);
- serial.println("Stop")
- }
- if ( readString == "l")
- {
- motor1.write(110);
- motor2.write(100);
- serial.println("")
- }
- if ( readString == "r")
- {
- motor2.write(110);
- motor1.write(90);
- }
- if ( readString == "f")
- {
- motor1.write(0);
- motor2.write(180);
- }
- if ( readString == "b")
- {
- motor1.write(120);
- motor2.write(60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement