Commit 67e45d49 authored by BigOto2's avatar BigOto2
Browse files

Arduino I2C code

To send information from one arduino to another using I2C and two analog
pins on both.
parent c008ea8d
#include <Wire.h>
void setup()
{
Wire.begin(4);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
delay(10);
}
void receiveEvent(int howMany)
{
boolean c = Wire.read();
if (c)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
}
#include <Wire.h>
//With two arduino unos: Connect A4 to A4, A5 to A5, and share common ground.
void setup()
{
Wire.begin();
}
boolean message = 1;
byte x=0;
void loop()
{
Wire.beginTransmission(4);
Wire.write(message);
Wire.endTransmission();
delay(1000);
x++;
message = !message;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment