OTTO机器人之串口调试

版权声明:转载记得声明~~~ :) https://blog.csdn.net/ReCclay/article/details/82710385

发送对应的数据(十六进制发送),执行相应的动作。

这里写图片描述

#include <Servo.h> 
#include <Oscillator.h>
#include <US.h>
#include <Otto.h>

/*
                 --------------- 
                |     O   O     |
                |---------------|
RIGHT LEG 3==>  |               | <== LEFT LEG 2
                 --------------- 
                    ||     ||
RIGHT FOOT 5==>   -----   ------  <== LEFT FOOT 4
                 |-----   ------|
*/

#define PIN_LEFT_LEG   2   
#define PIN_RIGHT_LEG  3  
#define PIN_LEFT_FOOT  4  
#define PIN_RIGHT_FOOT 5 


#define TRIM_LEFT_LEG   0 
#define TRIM_RIGHT_LEG  0
#define TRIM_LEFT_FOOT  0 
#define TRIM_RIGHT_FOOT 0

Otto Otto;  
byte MyData = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("hello");

  Otto.init(PIN_LEFT_LEG,PIN_RIGHT_LEG,PIN_LEFT_FOOT,PIN_RIGHT_FOOT);
  Otto.home();
}

void loop() 
{
    if (Serial.available())
    {
        MyData = Serial.read();
    }
    switch(MyData)
    {
        case 1:
            Otto.jump(6, 1000);
            break;
        case 2:
            Otto.bend(6, 1000);
            break;
        case 3:
            Otto.shakeLeg(6, RIGHT);
            break;
        case 4:
            Otto.updown(6, 1000, BIG);
            break;
        case 5:
            Otto.swing(6, 1000, 50);
            break;

        default:
            break;
    }
    MyData = 0;
}  

猜你喜欢

转载自blog.csdn.net/ReCclay/article/details/82710385