

This is the code the master is using, note that I'm using serial to send commands from the computer and according to these commands, I'm writing to different addresses, in this case I used addresses 8 and 9. So the idea is with these codes, send the data from the Master. Wire.endTransmission()//you are done sending and someone can take over the line. Wire.write()//you write bytes as ints, characters or strings. Wire.beginTransmission(byte of address)//you are writing to an address always. Wire.begin()>//initialize the I2C when no address is provided thatmeans you are the Master.

The important methods to use with the Arduino master are these: I will use anArduino UNO to be the master to which the two digisparks are connected. To include this library, you have to use this at the top of the sketch: The Wire library, as it is called parses and deals with the timing and addressing, transmitting and recieving of data. I am starting to use fritzing to prototype these boards:Įach LED is controlled on the digispark's pin 1 which is the pin 6 or PB1 on the ATtiny85.Īrduino has a library for this protocol and communication which must be used on specific pins because the SCL and SDA lines refer to specific registers on the board's microprocessor. The image is a bit of a mess, but this is a diagram of what I connected. These are marked on the digispark accordingly. On the ATtiny, the SDA pin is PB0 or pin 5, while the SCL pin is the PB2 or pin 7. These are the only pins you can use for I2C. On an UNO, SDA is the A4 pin and the SCL is the A5 pin. Connected to the 5V on the arduino.Īlso, I provided 5V power and GND to the digisparks from the arduino. I connected the two digisparks to the SDA and SCL pins on the arduino, they were connected with two 4.5KOhm pull up resistors. Wire.begin(own_address) //enter the bus on specified address When they receive a specific character, they turn their LEDs on.īyte own_address = 4 //set own adress, changed to 2 in another board. Wire.begin() // join i2c bus (address optional for master)Īnd here is the code for the receiver boards. I initializes the I2C protocil, as well as the serial and when it receives certain letters from the computer, it sends specific characters to the receiver boards. Here you can see the I2C master receiving commands from serial on the computer, and then sends characters to each receiver board, which turn on their LEDs.Īnd here is the code for the master board which was my board. Your browser does not support the video tag. This is the wiring steup where we used a breadboard as a bus cable, both for the 5V and GND lines as well as the SDA/SCL lines. The board was designed to be as small as possible. I dod not include pull up resistprs, becase the SAMD has them internally. This is my board, you'll notice I just put some connectors in order to set up the I2C bus. On the SAMD11C the pins for SDA and SCL are pins PA14 and PA15. We decided to connect several of our boards together in a network, and have them comunicate between them. This address must be a 7-bit address number which means that the limit is 127 device addresses.Īrduino has a special library called Wire.h that works with the SAMD11C. In order to have multiple devices, all of the devices must have an address. Multiple devices can be connected to these two lines as long as at the end they have the pull up resistors. These two lines must always have pullup resistors, so that when they are idle, they are HIGH meaning that they are pulled to a 5V voltage. SCL > stands for "serial clock line" which is constantly alternating between high and low voltage, at a constant speed therefore the devices always know when to expect a bit. The devices pull it low to write the bits. SDA > stands for "serial data line" whcich transmits the bytes of your message, one bit at a time between frame bits and with start and stop condition bits. The devices are connected using two wires: Communication can be two way, but both master and slave devices have to have a way of knowing when to transmit. I2C is the same aas IIC which stands for Inter Integrated Circuit, it works with two wires and sends bits one at a time between a master device and a receiver device. The first thing was to learn how the serial I2C bus works. Running an I2C Bus Running an I2C with commercial boards Network Sockets using Python Touch OSC messages through IP Group Assignment I2C with SAMD11C

Home Assignments About Final Project Rodrigo Shiordia Week 14 Assignment: Networking and Communication
