Data Sheet

Core Spartan Documentation Modern Robotics, Inc
Version 3.0.3 Page 30
8. Three Wire Analog & Digital Sensors
All three wire sensors connect to either a digital port or an analog port. Therefore, if it is a
digital sensor it returns a value of either 0 or 1. If the sensor is analog it returns a value
between 0 and 255. The sensors consist of a black, red and yellow wire. The black wire is
the ground wire and must line up with the black bar on the right side of the port. The red
wire is the power wire that connects to 5V for all the sensors to operate on. The yellow wire
is the variable voltage line that ranges from 0V-5V and it is used to send or receive signal.
These sensors can be connected on the Core Spartan Controller using ports (D0 D11) or
(A0 A3) depending on if the sensor is digital or analog. Ports D0 and D1, Rx and Tx
respectively, should not have anything connected to them while uploading code to the
board as it can interfere with serial communications. Each sensor of this type uses either
the digital or analog class both with the ability to read and write. The constructor for the
class must be called at the beginning of user code. The constructors name is arbitrary and a
constructor must be called for each sensor being used. Refer to example programs for more
information on sensor usage.
I/O +5V Ground
The Core Spartan Library includes
wrapper classes for the default analog
and digital functions.
Analog Functions:
CORE_ANALOG(char port)
int read(void)
void write(int)
Digital Functions:
CORE_DIGITAL(char port)
int read(void)
void write(int)
Example:
CORE_ANALOG my_analog(A3);
CORE_DIGITAL my_digital(5);
value = my_analog.read();
my_digital.write(1);