8-битный Интерфейс I2C PCF8574

Тема в разделе "Arduino & Shields", создана пользователем arduin, 13 май 2017.

  1. arduin

    arduin Нерд

    Доброй ночи.

    Кто нибудь пробовал работать с данным интерфейсом.

    Пытаюсь передать сигнал на ардуино, но не получается.
    перепробовал кучу скетчей.


    Подскажите пожалуйста как подключить кнопку чтоб работала.


    Код (C++):
    /*
    *  i2ckeypad.pde - keypad/I2C expander interface example for Arduino
    *
    *  Copyright (c) 2009 Angel Sancho <angelitodeb@gmail.com>
    *  All rights reserved.
    *
    *
    *  LICENSE
    *  -------
    *  This program is free software: you can redistribute it and/or modify
    *  it under the terms of the GNU General Public License as published by
    *  the Free Software Foundation, either version 3 of the License, or
    *  (at your option) any later version.
    *
    *  This program is distributed in the hope that it will be useful,
    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    *  GNU General Public License for more details.
    *
    *  You should have received a copy of the GNU General Public License
    *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    *
    *
    *  EXPLANATION
    *  -----------
    *  This example was tested with PCF8574P and SPARKFUN 4x3 keypad wired
    *  as you can see in the image i2ckeypad_example_schema.png, and with
    *  default pin mapping of i2ckeypad library
    *
    *  R1, R2 and R3 are 10K
    */


    #include <Wire.h>
    #include <i2ckeypad.h>

    #define ROWS 4
    #define COLS 3

    // With A0, A1 and A2 of PCF8574 to ground I2C address is 0x20
    #define PCF8574_ADDR 0x20


    i2ckeypad kpd = i2ckeypad(PCF8574_ADDR, ROWS, COLS);

    void setup()
    {
      Serial.begin(9600);

      Wire.begin();

      kpd.init();

      Serial.print("Testing keypad/PCF8574 I2C port expander arduino lib\n\n");
    }

    void loop()
    {
      char key = kpd.get_key();

      if(key != '\0') {
            Serial.print(key);
      }
    }
     
     

    Вложения:

  2. sslobodyan

    sslobodyan Гик

    Линии SDA и SCL подтянуты к питанию через 4.7 килоома? На схеме не указано.
     
  3. arduin

    arduin Нерд

    Подтягивал, никакой разницы.
    Проблема пока не ясна, так как пробовал скетч для теста дисплея при нем не виснит если питание отрубить.


    Сейчас еще проблема появилась. У этого модуля есть 7 портов, которые должны передавть данные.
    Пытаюсь повесити кнопки на шину, но нет реакции, должны быть цифровые данные 0 или 1.

    И еще в схеме указано что подцепить надо на кнопку нолик, но тогда у меня замыкание происходит


    пробовал разные варианты не вышло.

    По этой схема получается замыкание.
     

    Вложения:

    • sch1[1].jpg
      sch1[1].jpg
      Размер файла:
      107,9 КБ
      Просмотров:
      631
  4. mcureenab

    mcureenab Гуру

  5. arduin

    arduin Нерд

    Пробовал и по этой статье, не получилось.