PJRC StoreTeensy 4.1, $31.50Teensy 4.0, $23.80TeensyMain PageHardwareGetting StartedTutorialHow-To TipsCode LibraryProjectsTeensyduinoMainDownload+InstallBasic UsageDigital I/OPWM & ToneTimingCode SecurityStartupUSB SerialUSB KeyboardUSB MouseUSB JoystickUSB MIDIUSB Flight SimSerialLibrariesMain ListGLCDLiquidCrystalOctoWS2811FastSPI_LEDMatrix/SpriteLedDisplayLedControlDogLcdST7565AltSoftSerialNewSoftSerialSoftwareSerialMIDIPS2KeyboardDmxSimpleFirmataWireSPIOneWireXBeeVirtualWireX10IRremoteTinyGPSUSBHostShieldEthernetBounceKeypadAudioEncoderPingCapacitiveSensorFreqCountFreqMeasureServoPulsePositionStepperAccelStepperFrequencyTimer2Tlc5940SoftPWMShiftPWMTimeTimeAlarmsDS1307RTCMetroTimerOneMsTimer2EEPROMReference Wire LibraryThe Wire library allows you to communicate with I2C devices, often alsocalled "2 wire" or "TWI" (Two Wire Interface).Download: Wire is included with ArduinoRichard Gemmell has written an improved I2C library for Teensy 4.0.Brian "nox771" has written an improved I2C library for Teensy 3.0.Hardware RequirementsI2C devices communicate with 2 signals, called SDA and SCL. Normally a4.7K pullup resistor is connected between each signal and power (+3.3V on Teensy 3.0,+5V on Teensy 2.0). On Teensy 2.0, 4.0, and 4.1, the weak internal pullup resistors may be sufficientfor short wires to a single device. Because the internal resistors are so weak,communication may be slower or unreliable if the wires are long.BoardPortNameDefaultSDA PinDefaultSCL PinAlternateSDA PinAlternateSCL PinNotesTeensy 2.0Wire65Teensy++ 2.0Wire10Teensy LCWire18191716Wire12322edit WireKinetis.h to useTeensy 3.0Wire18191716Teensy 3.2Wire18191716Wire13029Teensy 3.5Wire18198, 17, 34, 487, 16, 33, 47Wire13837Wire243Teensy 3.6Wire18198, 17, 34, 487, 16, 33, 47Wire13837Wire243Wire35657edit WireKinetis.h to useTeensy 4.0Wire1819Wire117163637Wire22524MicroMod TeensyWire1819Wire12524Wire217163637Wire34140Teensy 4.1Wire1819Wire117164445Wire22524Teensy LC & 3.0-3.6 requires pullup resistors to +3.3V. The on-chip pullups are not used.1K to 4.7K resistors are recommended for most applications. The on-chip pullup resistors inTeensy 2.0, Teensy 4.0, Teensy 4.1 are very weak. Usually communication with 1 chipat 100kHz can work, but with poor signal quality. The on-chip resistors are not enough forseveral chips or higher speeds.The Wire library is not compatible with Teensy 1.0.Basic UsageWire.begin()Begin using Wire in master mode, where you will initiate and controldata transfers. This is the most common use when interfacing withmost I2C peripheral chips.
Masterwriter 2.0 Activation Code
With libraries that use Wire to access hardware, look for a begin()function or way to create that's library's instance to specify which port. Forexample, Adafruit_SSD1306.h allows creating your display instance this way:Adafruit_SSD1306 myDisplay(128, 64, &Wire1, -1);For libraries which does not provide a way to configure which port they use,your only option may be to edit the library code, replacing allWire withWire1 orWire2.Responding in Slave ModeWire.OnReceive(myReceiveHandlerFunction)Causes "myReceiveHandlerFunction" to be called when a master device sends data.This only works in slave mode. 2ff7e9595c
Comentarios