//********************************************************************** /* <KeyPad(4×4)のテストデータ送信用(マスター)> */ //********************************************************************** #define ACK 1 #define NO_ACK 0 //********************************************************************** void SwitchONcheck() { while (Button(&PORTB, 3, 1, 0) == 0) ; while (Button(&PORTB, 3, 1, 1) == 0) ; } //********************************************************************** void main() { unsigned short kp, l_cnt, c_cnt, cnt; // OSCCON = 0b01110000; // クロックを8Mhzに設定する。 ANSEL = 0b00000000; // A/D変換は使用しない。 TRISA = 0b00110000; TRISB = 0b00001111; // Lcd_Custom_Config(&PORTA, 1, 0, 7, 6, &PORTB, 5, 6, 7); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); // for (cnt = 0; cnt < 16; cnt++) { Lcd_Custom_Chr(1, cnt + 1, 0xFF); Delay_ms(50); } for (cnt = 0; cnt < 16; cnt++) { Lcd_Custom_Chr(2, cnt + 1, 0xFF); Delay_ms(50); } Lcd_Custom_Cmd(LCD_CLEAR); // l_cnt = 1; c_cnt = 1; // Soft_I2C_Config(&PORTA, 2, 3); // SDA, SCL // while (1) { // Soft_I2C_Start(); Soft_I2C_Write(0xF0); Soft_I2C_Write(0x00); Soft_I2C_Start(); Soft_I2C_Write(0xF1); kp = Soft_I2C_Read(NO_ACK); Soft_I2C_Stop(); // if (kp == 0x00) { Delay_ms(100); continue; } // Soft_I2C_Start(); Soft_I2C_Write(0xF0); Soft_I2C_Write(0x00); Soft_I2C_Write(0x00); Soft_I2C_Stop(); // Lcd_Custom_Chr(l_cnt, c_cnt, kp); c_cnt++; if (c_cnt == 17) { c_cnt = 1; l_cnt++; if (l_cnt == 3) l_cnt = 1; } Delay_ms(100); } } //**********************************************************************