Can I transfer information between 2 arduinos with analog0 and analog 1 pins?
I've been trying but i'm unable to do it.
Any help is appreciated
Can I transfer information between 2 arduinos with analog0 and analog 1 pins?
I've been trying but i'm unable to do it.
Any help is appreciated
It would help if you posted more of an explanation, and better yet, code and schematic.
Not sure what you have in mind, since the analog pins are read pins not for writing.
I'm trying to transfer information between two arduinos with analog 0 and analog 1 pins.
a0 and a1
master----
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop()
{
Wire.beginTransmission(4); // transmit to device #4
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}
slave----
#include <Wire.h>
void setup()
{
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop()
{
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
I've tried with
Wire.begin(0); or Wire.begin(1); and
Wire.beginTransmission(0); or Wire.beginTransmission(1); /
It is working only with analog4 and analog5
If I unplug A4 or A5 it does not work.
Thanks
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
JimboZa, thank you very much for your time.
The Arduino has hardware inside for I2C, SPI, Serial interface.
The I2C is fixed to A4 and A5 as JimboZA wrote.
You can however use software to toggle those pins and transfer data.
The SerialSoftware library does just that.
I think you can also create a serial port on A0 and A1.
SoftwareSerial mySerial(A0, A1); // RX, TX