
Well, have we evolved as prey (hehe)..?
Initiate the Wire library
and join the I2C bus as a master or slave.
address: the 7-bit slave address (optional);
if not specified, join the bus as a master.
Request bytes from another device.
The bytes may then be retrieved with the
available() and receive() functions.
address: the 7-bit address of the device to request bytes from
quantity: the number of bytes to request
Returns the number of bytes available
for retrieval with receive().
This should be called on a master device
after a call to requestFrom()
or on a slave inside the onReceive() handler.
Retrieve a byte that was transmitted
from a slave device to a master
after a call to requestFrom
or was transmitted from a master to a slave.
Registers a function to be called
when a slave device receives a transmission
from a master.
handler: the function to be called when the slave receives data;
this should take a single int parameter
(the number of bytes received from the master)
and return nothing,
e.g.: void myHandler(int numBytes)
Begin a transmission to the I2C slave device with the given address.
Subsequently, queue bytes for transmission with the send() function
and transmit them by calling endTransmission().
address: the 7-bit address of the device to transmit to
Sends data from a slave device
in response to a request from a master,
or queues bytes for transmission
from a master to slave device
(in-between calls to beginTransmission()
and endTransmission()).
value: a byte to send (byte)
string: a string to send (char *)
data: an array of data to send (byte *)
quantity: the number of bytes of data to transmit (byte)
Ends a transmission to a slave device
that was begun by beginTransmission()
and actually transmits the bytes
that were queued by send().
Register a function to be called
when a master requests data
from this slave device.
handler: the function to be called,
takes no parameters and returns nothing,
e.g.: void myHandler()
This library allows you to communicate with I2C / TWI devices.
On most Arduino boards,
SDA (data line) is on analog input pin 4, and
SCL (clock line) is on analog input pin 5.
On the Arduino Mega, SDA is digital pin 20 and SCL is 21.
There are both 7- and 8-bit versions of I2C addresses.
7 bits identify the device, and the eighth bit determines
if it's being written to or read from.
The Wire library uses 7 bit addresses throughout.
If you have a datasheet or sample code that uses 8 bit address,
you'll want to drop the low bit (i.e. shift the value one bit to the right),
yielding an address between 0 and 127.
/*Sets all of the bytes of the EEPROM to 0.*/
#include [EEPROM.h]
/*these should be Less-than & Greater-than brackets
but Blogger thinks they're HTML :-( */
void setup()
{
// write a 0 to all 512 bytes of the EEPROM
for (int i = 0; i [ 512; i++)
EEPROM.write(i, 0);
// turn the LED on when we're done
digitalWrite(13, HIGH);
}//end setup()
void loop()
{}//end empty looop
/* Stores values read from analog input 0 into the EEPROM.
These values will stay in the EEPROM when the board is turned off
and may be retrieved later by another sketch. */
/*Reads the value of each byte of the EEPROM
and prints it to the computer.*/
#include [EEPROM.h]
// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;
void setup()
{
Serial.begin(9600);
}//end setup()
void loop()
{
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);
Serial.print(address);
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();
// advance to the next address of the EEPROM
address = address + 1;
/* there are only 512 bytes of EEPROM, from 0 to 511, so if we're
on address 512, wrap around to address 0 */
if (address == 512)
address = 0;
delay(500);
}//end loop()
RT [Ω] 332 094 239 900 175 200 129 287 96 358 72 500 55 046 42 157 32 554 25 339 19 872 15 698 12 488 10 000 8059 6535 5330 | Temp Deg C - - - - -
-10 -05 0 05 10 15 20 25 30 35 40 |