Nucleo_PCF8574_led_iic

Dependencies:   PCF8574 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include "mbed.h"
00003 #include "PCF8574.h"
00004 
00005 PCF8574 io(D14,D15,0x70);//iic 设置:D14 SDA,D15 SCL
00006 
00007 int main()
00008 {
00009    while(1) 
00010     {
00011      io.write(0x0);
00012         if ((io.read()) == 16) 
00013         {
00014          io.write(0x01);
00015         }
00016         else if((io.read()) == 32)
00017         {
00018          io.write(0x02);
00019         }
00020         else if((io.read()) == 64)
00021         {
00022          io.write(0x04);
00023         }
00024         else if((io.read()) == 128)
00025         {
00026          io.write(0x08);
00027         }
00028     }
00029 }