So what's this EV3 Basic, anyway?
Built-In Support for I2C Communications and UART
What is I2C? I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave, single-ended, serial computer bus. It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers. Alternatively I²C is spelled I2C or IIC. It is a 2 line (plus common ground) communication method for one master device to control up to 112 slave devices.
What is UART? A universal asynchronous receiver/transmitter, abbreviated UART /ˈjuːɑrt/, is a computer hardware device that translates data between parallel and serial forms. The data format and transmission speeds are configurable. A UART is usually an individual (or part of an) integrated circuit (IC) used for serial communications over a computer or peripheral device serial port. UARTs are now commonly included in microcontrollers.
The I2C method in EV3 Basic
Let's dig into the I2C method introduced in EV3 Basic as part of the Sensor library:
Sensor.CommunicateI2C (port, address, writebytes, readbytes, writedata)
Communicates with devices using the I2C protocol over one of the sensor ports. This command addresses one device on the I2C-bus and can send and receive multiple bytes. This feature could be used to attach a custom sensor or to communicate with any device that is capable to be connected to the I2C bus as a slave.
port Number of the sensor port
address Address (0 - 127) of the I2C slave on the I2C bus
writebytes Number of bytes to write to the slave (maximum 31).
readbytes Number of bytes to request from the slave (maximum 32, minimum 1).
writedata Array holding the data bytes to be sent (starting at 0).
Returns An array holding the requested number of values. Index starts at 0.
Read more about the Sensor object in EV3 Basic.
Dig Deeper on Lego Mindstorms:
Have a Small and Basic day!
- Ninja Ed