السلام عليكم
ضمن النظام اي تم وضع مخططات له راجع مشاركه 116 من هذا الرابط
http://www.qariya.info/vb/showthread...612#post957612
يمكن أستخدام برتوكول I2C وبأستخدام متكامله PCA9555 يمكن زياده عدد مداخل او مخارج كحد الاقصى الى 16x8=128
او input=output =8x8=64
او يمكن أختيار ماتريد ضمن 128
كل هذه بسلكين فقط
الكود فحص للبوردات حيث (( البورد الرئيسي و board_main USING I2C V01))
كود:
//w3Lcd0 pin definitions:
sbit w3Lcd0_EN at LATC5_bit;
sbit w3Lcd0_DATA at LATC3_bit;
sbit w3Lcd0_CLOCK at LATC4_bit;
sbit led_lcd at LATC2_bit;
sbit w3Lcd0_EN_Direction at TRISC5_bit;
sbit w3Lcd0_DATA_Direction at TRISC3_bit;
sbit w3Lcd0_CLOCK_Direction at TRISC4_bit;
sbit led_lcd_Direction at TRISC2_bit;
//************************************//
//***************************** define speaker ***************************//
sbit speaker at LATD4_bit;
sbit speaker_dir at TRISD4_bit;
//****************************define variable && function ***************
char display_flag=0 , x=0;
unsigned char port0,port1;
void display();
//***************** end define variable && function **********************//
void init_pic()
{
ANSELA=0;
ANSELB=0;
ANSELC=0;
ANSELD=0;
ANSELE=0;
SLRCON=0;
//************************************************************************//
speaker_dir=0; speaker=0;
//*********************************************************************//
//*************** I2C ********************
I2C2_Init(400000);
config_port0(255,0x40);//address =0b0100 A2 A1 A0 R/W
config_port1(0,0x40);
write_port1(0xAA,0x40);
//********************************************//
//***LCD ***//
led_lcd_Direction=0;// lcd led
led_lcd=1;// on led for lcd
w3Lcd0_Init();
w3Lcd0_Command(_lcd_cursor_off); // to turn off Cursor
w3Lcd0_GotoYX(0,0);
w3Lcd0_CstrOut("welcome");
Delay_ms(1000); /* One second pause */
w3Lcd0_Command(_lcd_clear); // to turn off Cursor
w3Lcd0_GotoYX(0,0);
w3Lcd0_CstrOut("IN:");
w3Lcd0_GotoYX(1,0);
w3Lcd0_CstrOut("OUT:");
}
void main()
{
init_pic();
speaker=1;
delay_ms(1000);
speaker=0;
while(1)
{
port0=read_port0(0x40);
delay_ms(100);
display();
write_port1(port0,0x40);
}
}
//******************************************//
void display()
{
unsigned char input_value ;
display_flag=0;
w3Lcd0_GotoYX(0,8);
for(x=0;x<8;x++)
{
if(port0&(1<<x)) w3Lcd0_WriteChar('1');
else w3Lcd0_WriteChar('0');
}
w3Lcd0_GotoYX(1,8);
port1=read_port1(0x40);
for(x=0;x<8;x++)
{
if(port1&(1<<x)) w3Lcd0_WriteChar('1');
else w3Lcd0_WriteChar('0');
}
}
http://up.top4top.net/downloadf-top4...9b261-rar.html
ملاحظه في مثال مرفق يحتوي على مكتبه PCA9555 جاهزه يمكن أستخدامها بسهوله مجرد ضبط الاعدادات وعمليه القراءه والكتابه بشكل سهل جدا