Pages: [1]   Go Down
Author Topic: Master Writer/Slave Receiver with analog 0 and analog 1  (Read 659 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 106
Posts: 4692
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to transfer information between two arduinos with analog 0 and analog 1 pins.

a0 and a1

http://arduino.cc/en/Tutorial/MasterWriter


master----

Code:
#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----
Code:
#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: [code] [/code] tags added.
« Last Edit: April 30, 2013, 03:22:14 pm by Coding Badly » Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 106
Posts: 4692
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

JimboZa, thank you very much for your time.
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
http://arduino.cc/en/Reference/SoftwareSerial

Code:
  SoftwareSerial mySerial(A0, A1); // RX, TX
Logged

Pages: [1]   Go Up
Jump to: