26
STEP1:
Plug the Crowtail-Motor Base Shield onto
the Arduino or Crowduino board.
Hardware Connection
STEP2:
Connect Crowtail-9G Servo and Crowtail-LED
to D5 and D7 port of Crowtail-Motor Base Shield.
Connect Crowtail-Ultrasonic Ranging Sensor to D2&D3
port of Crowtail-Motor Base Shield. The complete
connection is as follows.
The function of servo rotation. The prototype of this function is “ServoObject.write()”, The parameter in
parentheses is the angular position you need the servo to rotate to, for our 180 degrees servo, the
range of parameters you can enter is 0-180 degrees.
Servo rotation function: myservo.write(90); myservo.write(angle);
Remap numbers from one range to another. That is, if the value is "fromLow", the mapped value will
be "toLow". If the value is "fromHigh", then the mapped value will be "toHigh". When "value" is from
other values from fromLow to fromHigh, it is also mapped to between toLow and toHigh in equal
proportions. So here we map the value of pos (between 200 and 800) to angle(between 0 and 180).
For example, if the value of joystick pos is 300, after using the map() function, it will become about 30
and be assigned to the variable: angle.
Arduino math function map():int gapValue = map(value, fromLow, fromHigh,
toLow, toHigh)
pin it is connected to. For example, our code is to connect the servo to D5 port.
When we go to some commercial buildings, the gate will open automatically when we walk to the door.
Very convenient, right? In this lesson, we will use our own way to make a mini smart door using
ultrasonic, servo and led modules. When we stand in front of the door, the door can open automatically.
In addition, the red led can indicate the opening and closing of the door.
Lesson 12 – Smart door
Introduction
Arduino Uno/Crowduino Uno x1
Crowtail - Motor Base Shield x1
Crowtail - 9G Servo x1
Crowtail - Ultrasonic Ranging Sensor x1
Crowtail - LED x1
Crowtail - Cable x2
Required Parts
Содержание Crowtail Deluxe Kit
Страница 47: ......