mirror of
https://github.com/sipeed/Maixduino.git
synced 2026-03-03 09:04:00 +01:00
25
libraries/Wire/examples/i2c_rxtx/i2c_rxtx.ino
Normal file
25
libraries/Wire/examples/i2c_rxtx/i2c_rxtx.ino
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin (115200);
|
||||
|
||||
// Leonardo: wait for serial port to connect
|
||||
while (!Serial)
|
||||
{
|
||||
}
|
||||
|
||||
Serial.println ();
|
||||
Serial.println ("I2C Testing ...");
|
||||
byte count = 0;
|
||||
|
||||
Wire.begin();
|
||||
Wire.beginTransmission(0x3C);
|
||||
Wire.write(0x80);
|
||||
Wire.write(0xAF);
|
||||
Wire.endTransmission();
|
||||
Serial.println ("Done.");
|
||||
|
||||
} // end of setup
|
||||
|
||||
void loop() {}
|
||||
40
libraries/Wire/examples/i2c_scaner/i2c_scaner.ino
Normal file
40
libraries/Wire/examples/i2c_scaner/i2c_scaner.ino
Normal file
@@ -0,0 +1,40 @@
|
||||
// I2C Scanner
|
||||
// Written by Nick Gammon
|
||||
// Date: 20th April 2011
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin (115200);
|
||||
|
||||
// Leonardo: wait for serial port to connect
|
||||
while (!Serial)
|
||||
{
|
||||
}
|
||||
|
||||
Serial.println ();
|
||||
Serial.println ("I2C scanner. Scanning ...");
|
||||
byte count = 0;
|
||||
|
||||
Wire.begin();
|
||||
for (byte i = 8; i < 120; i++)
|
||||
{
|
||||
Wire.beginTransmission (i);
|
||||
if (Wire.endTransmission () == 0)
|
||||
{
|
||||
Serial.print ("Found address: ");
|
||||
Serial.print (i, DEC);
|
||||
Serial.print (" (0x");
|
||||
Serial.print (i, HEX);
|
||||
Serial.println (")");
|
||||
count++;
|
||||
//delay (1); // maybe unneeded?
|
||||
} // end of good response
|
||||
} // end of for loop
|
||||
Serial.println ("Done.");
|
||||
Serial.print ("Found ");
|
||||
Serial.print (count, DEC);
|
||||
Serial.println (" device(s).");
|
||||
} // end of setup
|
||||
|
||||
void loop() {}
|
||||
@@ -6,4 +6,4 @@ sentence=Allows the communication between devices or sensors connected via Two W
|
||||
paragraph=
|
||||
category=Signal Input/Output
|
||||
url=http://arduino.cc/en/Reference/Wire
|
||||
architectures=riscv
|
||||
architectures=k210
|
||||
|
||||
Reference in New Issue
Block a user