Created
May 10, 2020 05:59
-
-
Save kamiyaowl/b3810792df7f7d647064894aa6efe5d6 to your computer and use it in GitHub Desktop.
I2C Scanner for Wio Terminal(fork from https://github.com/m5stack/M5Stack/blob/master/examples/Advanced/I2C_Tester/I2C_Tester.ino)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************ | |
M5StackFire I2C Scanner | |
The M5StackFire has a connector for I2C devices. | |
This program scans the addresses 1-127 continuosly and shows | |
the devices found on the TFT. | |
The M5Stack fire has two internal I2C devices at address 0x68 and 0x75. | |
If they do not appear on the TFT it could mean you made a short cut on | |
the I2C bus. | |
October 2018, ChrisMicro | |
************************************************************************/ | |
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip | |
#include <SPI.h> | |
#include <Wire.h> | |
#define TFT_GREY 0x5AEB // New colour | |
TFT_eSPI tft = TFT_eSPI(); // Invoke library | |
void setup() | |
{ | |
tft.init(); | |
tft.setRotation(2); | |
Wire.begin(); | |
delay(3000); | |
tft.fillScreen(TFT_BLACK); | |
} | |
int textColor = TFT_YELLOW; | |
void loop() | |
{ | |
int address; | |
int error; | |
tft.setCursor(0, 0); | |
tft.println("scanning Address [HEX]"); | |
for (address = 1; address < 127; address++) | |
{ | |
Wire.beginTransmission(address); | |
error = Wire.endTransmission(); | |
if (error == 0) | |
{ | |
tft.print(address, HEX); | |
tft.print(" "); | |
} | |
else | |
tft.print("."); | |
delay(10); | |
} | |
if (textColor == TFT_YELLOW) | |
textColor = TFT_GREEN; | |
else | |
textColor = TFT_YELLOW; | |
tft.setTextColor(textColor, TFT_BLACK); | |
} |
Author
kamiyaowl
commented
May 10, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment