![]() ![]() SDA and SCL are normally defined by the standard TWI libraries as PB2 and PB0. The pinout for normal use is in the picture to the right. There are two steps to adapting this to your project: change the pins and port definitions and match the delay clock speed. Below we’ll walk you through, step by step, on what we did to make this library work for the Attiny and the Atmega. We had to adapt this library for use in a project where we wanted to use the Attiny and Atmega. ![]() The library can be downloaded here and can be adapted for both the Attiny and Atmega chips. Peter Fleury has written a great I2C Master Library here. While there are many examples of how to use I2C and other 2-wire protocols on Atmel chip’s designated pins, how do you develop an I2C master on non-standard pins? it’s an invaluable way to reach sensors in microcontroller projects. TinyWireS.begin(I2C_SLAVE_ADDR) // init I2C Slave mode #define I2C_SLAVE_ADDR 0x26 // i2c slave address Serial.println("No I2C devices found\n") ĭelay(5000) // wait 5 seconds for next scanĪnd here is my code for my ATtiny85: #include "TinyWireS.h" // wrapper class for I2C slave routines Serial.print("Unknown error at address 0x") Serial.print("I2C device found at address 0x") a device did acknowledge to the address. The i2c_scanner uses the return value of ![]() Here is my code for my photon: #include "application.h"įor(address = 1 address < 127 address++ ) I’m trying to configure a Photon and attiny85 using I2C using the Arduino I2C scanner recommended in the Particle I2C tutorial and have checked both my code and wiring, but I keep getting a “No devices found” message in my serial monitor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |