//********************************************************************** /*  『輝度可変型LED(10灯)ユニットのテストデータ送信用(マスター)』 */ //********************************************************************** #define SW GPIO.F3 #define LED GPIO.F2 #define ON 1 #define OFF 0 #define ACK 1 #define NO_ACK 0 //********************************************************************** void SwitchONcheck() { while (Button(&GPIO, 3, 1, 0) == 0) ; while (Button(&GPIO, 3, 1, 1) == 0) ; } //********************************************************************** void main() { unsigned short cnt, dat; // CMCON0 = 0b00000111; ANSEL.ANS0 = 0; ANSEL.ANS1 = 0; ANSEL.ANS2 = 0; ANSEL.ANS3 = 0; ADCON0.VCFG = 0; TRISIO = 0b00001011; OSCCON = 0b01110000; // for (cnt = 0; cnt < 10; cnt++) { LED = ON; Delay_ms(50); LED = OFF; Delay_ms(50); } // Soft_I2C_Config(&GPIO, 4, 5); // SDA, SCL // while (1) { SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xE0); Soft_I2C_Write(0x00); Soft_I2C_Write(255); Soft_I2C_Write(128); Soft_I2C_Write(64); Soft_I2C_Write(32); Soft_I2C_Write(16); Soft_I2C_Write(8); Soft_I2C_Write(4); Soft_I2C_Write(2); Soft_I2C_Write(1); Soft_I2C_Write(0); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xE0); Soft_I2C_Write(0x00); Soft_I2C_Write(0); Soft_I2C_Write(1); Soft_I2C_Write(2); Soft_I2C_Write(4); Soft_I2C_Write(8); Soft_I2C_Write(16); Soft_I2C_Write(32); Soft_I2C_Write(64); Soft_I2C_Write(128); Soft_I2C_Write(255); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xE0); Soft_I2C_Write(0x00); Soft_I2C_Write(1); Soft_I2C_Write(4); Soft_I2C_Write(16); Soft_I2C_Write(64); Soft_I2C_Write(255); Soft_I2C_Write(255); Soft_I2C_Write(64); Soft_I2C_Write(16); Soft_I2C_Write(4); Soft_I2C_Write(1); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xE0); Soft_I2C_Write(0x00); Soft_I2C_Write(255); Soft_I2C_Write(64); Soft_I2C_Write(16); Soft_I2C_Write(4); Soft_I2C_Write(1); Soft_I2C_Write(1); Soft_I2C_Write(4); Soft_I2C_Write(16); Soft_I2C_Write(64); Soft_I2C_Write(255); Soft_I2C_Stop(); // SwitchONcheck(); // Soft_I2C_Start(); Soft_I2C_Write(0xE0); Soft_I2C_Write(0x00); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Write(rand() / 256); Soft_I2C_Stop(); // for (cnt = 0; cnt < 10; cnt++) { LED = ON; Delay_ms(50); LED = OFF; Delay_ms(50); } } } //**********************************************************************