23
STEP1:
Plug the Crowtail-Motor
Base Shield onto the Arduino or
Crowduino board.
Hardware Connection
STEP2:
Connect Crowtail-Thumb
Joystick to A4&A5 port of Crowtail-
Motor Base Shield. The complete
connection is as follows.
Open the
P10_Use_Of_The_Joystick
with Arduino IDE and upload it.
Open the serial monitor, when you drag the joystick to different positions, you can see that the joystick
will print the corresponding value, and you will also see the direction prompts, including up and down,
left and right. But in fact, It can also detect the direction of the two axes at the same time! For
example, the upper right direction.
What will you see
1. Declare two variables to store x, y axes value of joystick.
2. Initialize the serial monitor and set the baud rate for it.
3. Read the value of x, y axes of the joystick and store them in two variables.
4. Print the x, y axes value of joystick in decimal.
5. Use if/else statement to judge the direction of the joystick and print them.
Code overview
they are actually two potentiometers. The resistor is 10k for each. The
joystick also has a push-button that is could be used for special
applications. When the module is in the working mode it will output two
analog values representing two directions. The value is restricted in a
little smaller range (e.g 200~800)compared to the normal joystick, while
it is around 1023 when the button is pushed so that the MCU can detect
the action of pressing.In this lesson,we will print the working status of
the joystick in different positions on the serial monitor,
so that we can use it later to control the small smart car made by yourselves, such as the head rotation
(servo), movement ( motor), horn (buzzer), light (led), etc.
Arduino Uno/Crowduino Uno x1
Crowtail - Motor Base Shield x1
Crowtail - Thumb Joystick x1
Crowtail - Cable x1
Required Parts
Содержание Crowtail Deluxe Kit
Страница 47: ......