Keywish Hummer-Bot-2.0 Instruction Manual page 73

Table of Contents

Advertisement

3.2.4.5 Wire connection
As shown in the below figure, the servo's "S" is connected to pin 13, the ultrasonic "Trlg" is connected
to pin 2, the "Echo" is connected to pin 3, the "VCC" pin is connected to VCC, and the "GND" pin is
connected to GND.
Figure 3.2.33 Wiring diagram of steering gear, ultrasonic wave and expansion board
3.2.4.6 Software design
3.2.4.5.1 Program Code
Code path "hummer-bot\Lesson\ModuleDemo\UltrasonicAvoidance\UltrasonicAvoidance"
#include "Ultrasonic.h"
#define INPUT1_PIN 6
#define INPUT2_PIN 10
#define INPUT4_PIN 9
#define INPUT3_PIN 5
byte TrigPin
= 2;
byte EchoPin
= 3;
byte ServoPin
= 13;
const int
leftPin
const int
rightPin
int
da, dl, dr;
byte
left, right;
Ultrasonic
mUltrasonic(TrigPin,EchoPin,ServoPin);
void
setup() {
Serial.begin(9600);
pinMode(INPUT1_PIN, OUTPUT);
pinMode(INPUT2_PIN, OUTPUT);
pinMode(INPUT3_PIN, OUTPUT);
pinMode(INPUT4_PIN, OUTPUT);
mUltrasonic.SetServoBaseDegree(90);
// PWMB
// DIRB --- right
// PWMA
// DIRA --- left
= A3;
= A4;
70

Advertisement

Table of Contents
loading

Related Products for Keywish Hummer-Bot-2.0

Table of Contents