i2c communication between an Arduino Uno and an Arduino Mega 2560

preview_player
Показать описание
My Amazon recommended products:

I set up an i2c bus and connect an Arduino 2560 as the master device, and an Arduino Uno as the slave device. The Arduino Mega tells the Arduino Uno to turn an LED connected to the UNO off and on at 3 second intervals.
Рекомендации по теме
Комментарии
Автор

HERE IS CODE

MASTER:
#include<Wire.h>
void setup() {

Wire.begin();
delay(2000);
}

void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(5);
Wire.write('H');
Wire.endTransmission();
delay(250);

Wire.beginTransmission(5);
Wire.write('L');
Wire.endTransmission();
delay(250);
}


SLAVE:
#include<Wire.h>

void setup() {
Wire.begin(5);
Wire.onReceive(receiveEvent);

pinMode(8, OUTPUT);
digitalWrite(8, LOW);
}

void loop() {
}

void receiveEvent(int howMany)
{
while(Wire.available())
{
char c=Wire.read();
if (c=='H'){
digitalWrite(8, HIGH);
}
else if(c=='L'){
digitalWrite(8, LOW);
}
}
}

Nomankhan-jvnk
Автор

Extremely helpful video.

Getting ready to do almost the same thing, but in reverse.  The Uno will send commands and receive some data from the Mega.  The Mega will run a bunch of various outputs and do a little bit of processing.

But I'm using the small 2.4 GHz transceivers instead of a wire.

tomwade
Автор

Subscribed! Thanks for this excellent tutorial. This is how Arduino teaching should be done. Liked the side by side screen comparisons. This is a multi-concept packed demo, I like it!

akompsupport
Автор

phi: the address 5 is arbitrary.  IT could be 8... as long as the master and slave are using the same address to communicate

viewfromadistance
Автор

FANTASTIC !!! Thank you for this great video :)

Kepler
Автор

 A question, If you want to connect a 3Vcc sensor to ARDUINO  which handling 5Vdc. You can connect the sensor to the line of 3.3V of ARDUINO, but what happens with I2C communication lines? The I2C of sensor is a collector open? Thank you very much for your help.

jogomeza
Автор

it's doesn't work! Can you explain this problem? Why I2C address arduino is 5?

hailuu
Автор

The link does not work... use github for a change!! opensource and protect you code and ideas, . event it is something simple

teslacoilkv
Автор

there is no predefined adress in the arduino, so you can use what you want

Автор

No need to power the SCI/SCL line with +5V... this is ridiculous....

yoyomario
Автор

Why the heck would you do this when 2.4 GHz communication costs $0.76 on e-bay and requires no wires?

SteelBlueVision
Автор

Nice video!! in which two pin you connected the last wire?

StevensNF
Автор

Is it possible to do the same thing but by using Bluetooth ?!!

adelmurad
Автор

I am new to arduino and circuit so maybe this is a dumb question: Can I know how does the uno board got powered? Is that related to the common ground?

efmvwwj
Автор

Do both arduinos has each Vcc or Where is it voltage source?

alexlo
Автор

hey bro!!nice video but the link doesn t work! xD
Please resolve this problem. THANK YOU :D

dariocardamone
Автор

Hi
My brother wants help
I want to send three values (numbers) from Arduino (Master) to three Arduino refunds (Slave) using the I2C protocol.

said
Автор

sir please respond we need your help on our research study, how can we viceversa it? mega as a slave and uno as a master?? please answe thankyou

ygonakylet.
Автор

What purpose does the common ground serve?

Awesomekid
Автор

you need to be a bit more organised lol, joke, good vid

glynnhmlsg