Purpose
Get the value of an Analog Channel (joystick) on a remote controller connected to the CrcDuino via a CrcConnect module.
When to use
Whenever you need to use the position of a remote controller joystick.
Where to use
Most probably in the void loop()
part of your .ino
file, since we’d usually want to actively monitor the value.
Click here to learn more on the CrcConnect system, that allows to control a CrcDuino using popular off-the-shelf remote controllers.
If not connection is established with a remote controller via a CrcConnect module, ReadAnalogChannel()
returns a value of 0
. Depending on the application, it might be useful to validate the status of the connection using IsCommValid().
This function requires the use of the following CrcLib functions at some point of your .ino
file in order to work properly:
Returns
This function returns the value of the analog channel mentioned as the function’s argument as a signed char
type. The value returned will range between -128 and 127, proportionally to the position of the joystick. The returned value will be:
-128
, if the joystick is at the maximum left position (for x axis channels) or maximum down position (for y axis channels)0
, if the joystick is at the middle position of the axis, or if no connection is established between a remote controller and the CrcDuino (via a CrcConnect Module)127
, if the joystick is at the maximum right position (for x axis channels) or maximum up position (for y axis channels)
Main prototype and parameters
static int8_t Crc::CrcLib::ReadAnalogChannel(ANALOG channel)
The following parameters must be passed to the function for it to work properly:
channel
: The name of the joystick channel you want to read the value of. Must be of the typeANALOG
.
Overloads
This function does not have any overloads. It can only be used as described by the main prototype.
Examples
More on this function
There is sadly nothing more to be said about this function…
Related articles
-
CrcConnect Module Details (Système CrcDuino System) —
This page presents the CrcConnect module that allows controlling a CrcDuino board using a remote controller.
Introduction
The CrcConnect is a device that allows to send commands to a CrcDuino using a remote controller. The CrcConnect serves as a data relay; it takes information from a controller (using a wire), and sends this information to a CrcDuino wirelessly using a pair of Xbee Modules.
-
CrcLib: How to access the remote controller buttons (Système CrcDuino System) —
This page presents how CrcLib functions can use a remote controller buttons and joystick states. It details the different types declared in CrcLib.
Analog
-
IsCommValid() (Système CrcDuino System) —
Purpose
Know if a remote controller connected to the CrcDuino via a CrcConnect module.
When to use
-
ReadAnalogChannel() (Système CrcDuino System) —
Purpose
Get the value of an Analog Channel (joystick) on a remote controller connected to the CrcDuino via a CrcConnect module.
When to use
-
ReadDigitalChannel() (Système CrcDuino System) —
Purpose
Get the value of a Digital Channel (button) on a remote controller connected to the CrcDuino via a CrcConnect module.
When to use
Add Comment