D-0006

From 52Pi Wiki
Revision as of 12:00, 19 March 2020 by Yoyojacky (talk | contribs) (Created page with "==PCF8574T LCD Driver Board== ==Description== ==Features== ==Gallery== ==Package Includes== ==Reference== * PCF8574T Chip Datasheet: File:PCF8574T Datasheet.pdf * Wirin...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

PCF8574T LCD Driver Board

Description

Features

Gallery

Package Includes

Reference

Demo Code For Handle PCF8574T

  • Download and reinstall wiringPi liberary
 
sudo apt -y purge wiringpi
hash -r
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb 
  • C++ language
#include <stdio.h>
#include <time.h>
#include <string>

#include <wiringPi.h>
#include <pcf8574.h>

using namespace std;
int main (int argc, char *argv[]){
	printf("Raspberry Pi initializing...\n");

        wiringPiSetup();
	pcf8574Setup(100, 0x38);

	for (int i = 0; i < 8; ++i){
    		pinMode(100 + i, OUTPUT);
	}

        int b=0;
        while( 1==1 ){
                printf("LOOP %u\n", b);
                for (int i = 0; i < 8; ++i){
                    digitalWrite(100 + i, i==b ? 0 : 1);
                }
                b++;
		if( b >= 8 ) b=0;
		delay(1000);

	}

	delay(1000);
	digitalWrite(100 + 0, 0);

	delay(1000);
        digitalWrite(100 + 0, 1);

	return 0;
}
  • Compile and run it.
g++ pcf8574.cpp -o pcf8574 -lwiringPi -std=c++11
./pcf8574

Python Demo Code