#include <Servo.h>
int in1 = 5;
int in2 = 6;
int in3 = 7;
int in4 = 8;
Servo myservo;
Servo myservo2;
Servo myservo3;
int pos = 0;
int pos_2=0;
int i;
int j;
int k;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);
myservo.attach(9); // 该舵机由arduino第九脚控制
myservo2.attach(10);
myservo3.attach(3);
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available())
{
char c=Serial.read();
switch©{
case’Q’:
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
Serial.println(“机器人协会\n”);
break;
case’H’:
digitalWrite(in1,LOW);