Go Down

Topic: Master Writer/Slave Receiver with analog 0 and analog 1 (Read 763 times) previous topic - next topic


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.


Apr 30, 2013, 04:59 pm Last Edit: Apr 30, 2013, 10:22 pm by Coding Badly Reason: 1
I'm trying to transfer information between two arduinos with analog 0 and analog 1 pins.

a0 and a1



Code: [Select]
#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


Code: [Select]
#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()

// 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.


Moderator edit: [code] [/code] tags added.


It's only supposed to work on A4 and A5, which are the TWI SDA and SCL pins according to this


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.

Code: [Select]

  SoftwareSerial mySerial(A0, A1); // RX, TX

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131