Reference+
Name
write()
Class
I2C
Description
Add bytes to be written to the device
You must call beginTransmission() before calling this function. The actual
writing takes part when read() or endTransmission() is being called.
Examples
import processing.io.*; I2C dac; void setup() { //printArray(I2C.list()); dac = new I2C(I2C.list()[0]); } void draw() { background(map(mouseX, 0, width, 0, 255)); // send value over I2C to a digital-to-analog // converter with address 96 (hex 0x60) int val = int(4095 * map(mouseX, 0, width, 0.0, 1.0)); dac.beginTransmission(0x60); dac.write(val >> 8); dac.write(val & 255); dac.endTransmission(); }
Syntax
.write(out)
Parameters
out
(byte[], String, int, byte)
bytes to be writtenout
(String, byte, int)
string to be writtenout
(int, byte)
single byte to be written, e.g. numeric literal (0 to 255, or -128 to 127)out
(byte, int)
single byte to be written
Return
void
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.