Taisomas Mcp23017
Jump to navigation
Jump to search
Dėmesio: Jūs nesate prisijungęs. Jūsų IP adresas bus viešai matomas, jei atliksite kokius nors keitimus. Jeigu prisijungsite arba sukursite paskyrą, jūsų keitimai bus priskirti jūsų naudotojo vardui; drauge įgysite naujų galimybių.
Keitimas gali būti atšauktas. Prašome patikrinti palyginimą, esantį žemiau, kad patvirtintumėte, kad jūs tai ir norite padaryti, ir tada išsaugokite pakeitimus, esančius žemiau, kad užbaigtumėte keitimo atšaukimą.
Dabartinė versija | Jūsų tekstas | ||
7 eilutė: | 7 eilutė: | ||
= ESP32 Wiring = | = ESP32 Wiring = | ||
− | + | * SDA -> pin 21 | |
− | + | * SCL -> pin 22 | |
− | + | * VSS -> GND | |
− | + | * VDD -> VIN | |
− | + | * 17 -> GND | |
− | + | * 16 -> GND | |
− | * | + | * 15 -> GND |
− | * | ||
− | * | ||
− | * | ||
− | * | ||
− | * | ||
− | * | ||
− | |||
− | |||
<Syntaxhighlight lang="cpp"> | <Syntaxhighlight lang="cpp"> | ||
+ | // ESP32 I2C Scanner | ||
+ | // Based on code of Nick Gammon http://www.gammon.com.au/forum/?id=10896 | ||
+ | // ESP32 DevKit - Arduino IDE 1.8.5 | ||
+ | // Device tested PCF8574 - Use pullup resistors 3K3 ohms ! | ||
+ | // PCF8574 Default Freq 100 KHz | ||
#include <Wire.h> | #include <Wire.h> | ||
− | + | void setup() | |
− | void setup() { | + | { |
− | + | Serial.begin (115200); | |
− | + | Wire.begin (21, 22); // sda= GPIO_21 /scl= GPIO_22 | |
− | + | } | |
+ | void Scanner () | ||
+ | { | ||
+ | Serial.println (); | ||
+ | Serial.println ("I2C scanner. Scanning ..."); | ||
+ | byte count = 0; | ||
+ | Wire.begin(); | ||
+ | for (byte i = 8; i < 120; i++) | ||
+ | { | ||
+ | Wire.beginTransmission (i); // Begin I2C transmission Address (i) | ||
+ | if (Wire.endTransmission () == 0) // Receive 0 = success (ACK response) | ||
+ | { | ||
+ | Serial.print ("Found address: "); | ||
+ | Serial.print (i, DEC); | ||
+ | Serial.print (" (0x"); | ||
+ | Serial.print (i, HEX); // PCF8574 7 bit address | ||
+ | Serial.println (")"); | ||
+ | count++; | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | Serial.print ("Found "); | |
− | + | Serial.print (count, DEC); // numbers of devices | |
− | + | Serial.println (" device(s)."); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | void loop() | |
− | void loop() { | + | { |
− | + | Scanner (); | |
− | + | delay (100); | |
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |