Tutorial.MasterWriter History

Hide minor edits - Show changes to output

September 03, 2015, at 11:12 AM by Simone Maiocchi -
Changed lines 1-6 from:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] > [[Tutorial.Examples | Examples]] > Wire > MasterWriter
(:divend:)

(:*toc:)
to:
(:html:)
<div class="subHeader row">
<div class="breadcrumb columns large-10 medium-10">
<p>
<a class="wikilink" href="/en/Tutorial/HomePage">Tutorials </a>
> <a class="wikilink" href="/en/Tutorial/LibraryExamples"> Examples from Libraries </a> > Wire > master_writer
</p>
</div>
</div>
(:htmlend:)

Added line 74:
* [[DigitalPotentiometer]] - How to control an Analog Devices AD5171 Digital Potentiometer.
Deleted line 76:
* [[SPIDigitalPot]] - How to control a Analog Devices AD5171 Digital Potentiometer.
Added line 78:
August 24, 2015, at 11:10 AM by Simone Maiocchi -
August 24, 2015, at 11:00 AM by Simone Maiocchi -
Changed lines 12-14 from:
The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.

to:
The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.

August 24, 2015, at 10:41 AM by Simone Maiocchi -
Changed lines 11-13 from:
The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the Arduino or Genuino Master board pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock line changes from low to high (known as the rising edge of the clock pulse), a single bit of information, that will form in sequence the address of a specific device and a request for data, is transferred from the board to the I2C device over the SDA line. The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.

to:
The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the Arduino or Genuino Master board pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock line changes from low to high (known as the rising edge of the clock pulse), a single bit of information - that will form in sequence the address of a specific device and a a command or data - is transferred from the board to the I2C device over the SDA line. When this information is sent - bit after bit -, the called upon device executes the request and transmits it's data back - if required - to the board over the same line using the clock signal still generated by the Master on SCL as timing.
The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.

Changed lines 57-58 from:
!!!See Also:
to:
!!!See Also
August 24, 2015, at 10:31 AM by Simone Maiocchi -
Changed lines 1-16 from:
''Examples > Wire Library''

!!!Master Writer/Slave Receiver

Sometimes, the folks in charge just don't know when to shut up! In some situations, it can be helpful to set up two (or more!) Arduino boards to share information with each other. In this example, two Arduinos are programmed to communicate with one another in a Master Writer/Slave Receiver configuration via the [[ http://en.wikipedia.org/wiki/I2C | I2C synchronous serial protocol]]. Several functions of Arduino's [[Reference/Wire | ''' Wire Library''']] are used to accomplish this. Arduino 1, the Master, is programmed to send 6 bytes of data every half second to a uniquely addressed Slave Arduino. Once that message is received, it can then be viewed in the Slave Arduino's serial window.

The I2C protocol involves using two wires to send and receive data: a serial clock pin (SCL) that the Arduino pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock pulse changes from low to high (known as the rising edge of the clock), a bit of information is transferred from the Arduino to the I2C devices over the SDA line. When the clock pin changes from high to low (the falling edge of the clock), the called upon device transmits a bit of data back to the Arduino over the same line. The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.


Each Slave device to have its own unique address and both master and slave devices to take turns communicating over a the same data line line. In this way, it's possible for your Arduino to communicate with many device or other Arduinos using just two pins of your microcontroller, using each device's unique address.


(:div class=BOM :)
!!!Hardware Required
* (2) Arduino Boards
* hook-up wire
to:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] &gt; [[Tutorial.Examples | Examples]] &gt; Wire &gt; MasterWriter
Added lines 5-22:
(:*toc:)

!!Master Writer/Slave Receiver

Sometimes, the folks in charge just don't know when to shut up! In some situations, it can be helpful to set up two (or more!) Arduino or Genuino boards to share information with each other. In this example, two boards are programmed to communicate with one another in a Master Writer/Slave Receiver configuration via the [[ http://en.wikipedia.org/wiki/I2C | I2C synchronous serial protocol]]. Several functions of Arduino's [[Reference/Wire | ''' Wire Library''']] are used to accomplish this. Arduino 1, the Master, is programmed to send 6 bytes of data every half second to a uniquely addressed Slave. Once that message is received, it can then be viewed in the Slave board's serial monitor window opened on the USB connected computer running the Arduino Software (IDE).

The I2C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the Arduino or Genuino Master board pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock line changes from low to high (known as the rising edge of the clock pulse), a single bit of information, that will form in sequence the address of a specific device and a request for data, is transferred from the board to the I2C device over the SDA line. The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.


Each Slave device has to have its own unique address and both master and slave devices need to take turns communicating over a the same data line line. In this way, it's possible for your Arduino or Genuino boards to communicate with many device or other boards using just two pins of your microcontroller, using each device's unique address.


(:div class=BOM :)
!!!Hardware Required
* 2 Arduino or Genuino Boards
* hook-up wires
(:divend:)
Changed lines 29-31 from:
If powering the Arduinos independently is an issue, connect the 5V output of the Master Arduino to the VIN pin on the slave.

to:
If powering the boards independently is an issue, connect the 5V output of the Master to the VIN pin on the slave.

Changed lines 47-48 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.ino lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/hardware/arduino/avr/libraries/Wire/examples/master_writer/master_writer.ino lang=arduino tabwidth=4:)
Changed line 50 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/slave_receiver/slave_receiver.ino lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/hardware/arduino/avr/libraries/Wire/examples/slave_receiver/slave_receiver.ino lang=arduino tabwidth=4:)
Changed lines 58-70 from:
* [[Reference/WireBegin | @@Wire.begin()@@]]
* [[Reference/WireBeginTransmission | @@Wire.beginTransmission()@@]]
* [[Reference/WireEndTransmission | @@Wire.endTransmission()@@]]
* [[Reference/WireSend | @@Wire.send()@@]]
* [[Reference/WireOnReceive | @@Wire.OnReceive()@@]]
* [[Reference/WireAvailable| @@Wire.available)@@]]

* [[Reference/Wire | Wire Library]]
* [[digital_potentiometer]]
* [[master_reader]]


to:
* [[Reference/WireBegin | Wire.begin]]()
* [[Reference/WireBeginTransmission | Wire.beginTransmission]]()
* [[Reference/WireEndTransmission | Wire.endTransmission]]()
* [[Reference/WireSend | Wire.send]]()
* [[Reference/WireOnReceive | Wire.OnReceive]]()
* [[Reference/WireAvailable| Wire.available]]()


* [[Reference/Wire | Wire Library]] – Your reference for the Wire Library.
* [[SFRRanger_reader]] - how to read an ultra-sonic range finder interfaced via the I2C.
* [[master_reader | Master Reader/Slave Writer]] - Two Arduino are programmed to communicate with one another in a Master Reader/Slave Sender configuration via the I2C.
* [[SPIDigitalPot]] - How to control a Analog Devices AD5171 Digital Potentiometer.
\\
''Last revision 2015/08/24 by SM''
March 25, 2013, at 11:53 AM by Roberto Guido - corrected swapped references to SDA and SCL. Thanks Greg Jackson for alert
Changed line 22 from:
Connect pin 4 (the clock, or SCL, pin) and pin 5 (the data, or SDA, pin) on the
to:
Connect pin 5 (the clock, or SCL, pin) and pin 4 (the data, or SDA, pin) on the
November 16, 2011, at 04:41 AM by Scott Fitzgerald -
Changed lines 43-44 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.ino lang=arduino tabwidth=4:)
Changed line 46 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/slave_receiver/slave_receiver.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/slave_receiver/slave_receiver.ino lang=arduino tabwidth=4:)
September 22, 2010, at 01:00 PM by Tom Igoe -
Changed lines 10-12 from:
Because the 12C protocol allows for each enabled device to have it's own unique address, and as both master and slave devices to take turns communicating over a single line, it is possible for your Arduino to communicate (in turn) with many devices, or other Arduinos, while using just two pins of your microcontroller.

to:
Each Slave device to have its own unique address and both master and slave devices to take turns communicating over a the same data line line. In this way, it's possible for your Arduino to communicate with many device or other Arduinos using just two pins of your microcontroller, using each device's unique address.

September 22, 2010, at 12:58 PM by Tom Igoe -
Changed lines 7-8 from:
The I2C protocol involves using two wires to send and receive data: a serial clock pin (SCL) that the Arduino pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock pulse changes from low to high (known as the rising edge of the clock), a bit of information containing the address of a specific device and a request for data, is transferred from the Arduino to the I2C devices over the SDA line. When the clock pin changes from high to low (the falling edge of the clock), the called upon device transmits it's data back to the Arduino over the same line.
to:
The I2C protocol involves using two wires to send and receive data: a serial clock pin (SCL) that the Arduino pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock pulse changes from low to high (known as the rising edge of the clock), a bit of information is transferred from the Arduino to the I2C devices over the SDA line. When the clock pin changes from high to low (the falling edge of the clock), the called upon device transmits a bit of data back to the Arduino over the same line. The initial eight bits (i.e. eight clock pulses) from the Master to Slaves contain the address of the device the Master wants data from. The bits after that contain the memory address on the Slave that the Master wants to read data from or write data to, and the data to be written, if any.

September 22, 2010, at 09:21 AM by Christian Cerrito -
Changed line 41 from:
'''Master Writer Code - Arduino 1'''
to:
'''Master Writer Code - Program for Arduino 1'''
Changed line 44 from:
'''Slave Receiver Code - Arduino 2'''
to:
'''Slave Receiver Code - Program for Arduino 2'''
September 22, 2010, at 09:19 AM by Christian Cerrito -
Changed line 44 from:
'''Master Receiver Code - Arduino 2'''
to:
'''Slave Receiver Code - Arduino 2'''
September 22, 2010, at 09:19 AM by Christian Cerrito -
Changed lines 5-6 from:
Description
to:
Sometimes, the folks in charge just don't know when to shut up! In some situations, it can be helpful to set up two (or more!) Arduino boards to share information with each other. In this example, two Arduinos are programmed to communicate with one another in a Master Writer/Slave Receiver configuration via the [[ http://en.wikipedia.org/wiki/I2C | I2C synchronous serial protocol]]. Several functions of Arduino's [[Reference/Wire | ''' Wire Library''']] are used to accomplish this. Arduino 1, the Master, is programmed to send 6 bytes of data every half second to a uniquely addressed Slave Arduino. Once that message is received, it can then be viewed in the Slave Arduino's serial window.

The I2C protocol involves using two wires to send and receive data: a serial clock pin (SCL) that the Arduino pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices. As the clock pulse changes from low to high (known as the rising edge of the clock), a bit of information containing the address of a specific device and a request for data, is transferred from the Arduino to the I2C devices over the SDA line. When the clock pin changes from high to low (the falling edge of the clock), the called upon device transmits it's data back to the Arduino over the same line.

Because the 12C protocol allows for each enabled device to have it's own unique address, and as both master and slave devices to take turns communicating over a single line, it is possible for your Arduino to communicate (in turn) with many devices, or other Arduinos, while using just two pins of your microcontroller.

Changed lines 22-23 from:
master Arduino to their counterparts on the slave board. Make sure that both boards share a common ground.
to:
master Arduino to their counterparts on the slave board. Make sure that both boards share a common ground. In order to enable serial communication, the slave Arduino must be connected to your computer via USB.
September 22, 2010, at 08:48 AM by Christian Cerrito -
Changed lines 19-21 from:
If powered the Arduinos independently is an issue, the 5V output of the Master Arduino to the VIN pin on the slave.

to:
If powering the Arduinos independently is an issue, connect the 5V output of the Master Arduino to the VIN pin on the slave.

September 22, 2010, at 08:47 AM by Christian Cerrito -
Added lines 16-21:
Connect pin 4 (the clock, or SCL, pin) and pin 5 (the data, or SDA, pin) on the
master Arduino to their counterparts on the slave board. Make sure that both boards share a common ground.

If powered the Arduinos independently is an issue, the 5V output of the Master Arduino to the VIN pin on the slave.

September 22, 2010, at 08:42 AM by Christian Cerrito -
Changed line 30 from:
Master Writer Code
to:
'''Master Writer Code - Arduino 1'''
Changed line 33 from:
Master Receiver Code
to:
'''Master Receiver Code - Arduino 2'''
Changed lines 41-42 from:
* [Reference/WireBegin | @@Wire.begin()@@]]
to:

* [[Reference/WireBegin | @@Wire.begin()@@]]
Changed lines 46-48 from:
* [[Reference/WireRequestFrom | @@Wire.RequestFrom()@@]]
* [[Reference/WireReceive | @@Wire.receive()@@]]
to:
* [[Reference/WireOnReceive | @@Wire.OnReceive()@@]]
* [[Reference/WireAvailable| @@Wire.available)@@]]

* [[Reference/Wire | Wire Library]]
Changed lines 52-56 from:
* [[master_writer]]
* [[slave_receiver]]
* [[slave_sender]]

to:


September 22, 2010, at 08:29 AM by Christian Cerrito -
Changed lines 3-4 from:
!!!Master Sender/Slave Reader
to:
!!!Master Writer/Slave Receiver
Changed line 27 from:
Describe what's going on here
to:
!!!Code
Added line 30:
Master Writer Code
Added line 33:
Master Receiver Code
September 22, 2010, at 08:27 AM by Christian Cerrito -
Changed lines 39-40 from:
* [[Reference/CommandName | Reference page for this command]]
* [[Other example in this category]]
to:
* [Reference/WireBegin | @@Wire.begin()@@]]
* [[Reference/WireBeginTransmission | @@Wire.beginTransmission()@@]]
* [[Reference/WireEndTransmission | @@Wire.endTransmission()@@]]
* [[Reference/WireSend | @@Wire.send()@@]]
* [[Reference/WireRequestFrom | @@Wire.RequestFrom()@@]]
* [[Reference/WireReceive | @@Wire.receive()@@]]

* [[digital_potentiometer]]
* [[master_reader]]
* [[master_writer]]
* [[slave_receiver]]
* [[slave_sender]]

September 22, 2010, at 08:26 AM by Christian Cerrito -
Changed lines 3-4 from:
!!!Example Name
to:
!!!Master Sender/Slave Reader
September 22, 2010, at 08:25 AM by Christian Cerrito -
Changed lines 9-10 from:
* Arduino Board
to:
* (2) Arduino Boards
* hook-up wire
Changed lines 16-17 from:
%height=300px%[[Attach:ExampleCircuit_bb.png | Attach:ExampleCircuit_bb.png]]
to:
%height=250px%[[Attach:Master_Sender_bb.png | Attach:Master_Sender_bb.png]]
Changed line 24 from:
%height=300px%[[ Attach:ExampleCircuit_sch.png | Attach:ExampleCircuit_sch.png]]
to:
%height=300px%[[ Attach:Master_Sender_sch.png | Attach:Master_Sender_sch.png]]
September 22, 2010, at 07:52 AM by Christian Cerrito -
Added lines 30-31:

(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/slave_receiver/slave_receiver.pde lang=arduino tabwidth=4:)
Added lines 35-36:

September 16, 2010, at 11:59 PM by Tom Igoe -
Changed line 29 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.pde language=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.pde lang=arduino tabwidth=4:)
August 13, 2010, at 10:38 PM by Tom Igoe -
Added lines 1-35:
''Examples > Wire Library''

!!!Example Name

Description

(:div class=BOM :)
!!!Hardware Required
* Arduino Board
(:divend:)

!!!Circuit
(:div class=circuit :)

%height=300px%[[Attach:ExampleCircuit_bb.png | Attach:ExampleCircuit_bb.png]]

[-image developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]

(:divend:)

!!!Schematic
(:div class=circuit :)
%height=300px%[[ Attach:ExampleCircuit_sch.png | Attach:ExampleCircuit_sch.png]]
(:divend:)

Describe what's going on here

(:div class=code :)
(:source http://arduino.cc/en/pub/code/master/libraries/Wire/examples/master_writer/master_writer.pde language=arduino tabwidth=4:)
(:divend:)


!!!See Also:
* [[Reference/CommandName | Reference page for this command]]
* [[Other example in this category]]

Share