/**************************************************************** * * For * * Arduino analog input 5 - I2C SCL * Arduino analog input 4 - I2C SDA * ****************************************************************/ #include #define PE_ADD 0x20 // I2C-Addresse void setup() { Serial.begin(9600); Wire.begin(); Wire.beginTransmission(PE_ADD); byte error = Wire.endTransmission(); if(error == 0) { Serial.println("PE found"); } else { Serial.println("Ne, Alter. Ne."); } wr(PE_ADD, 0xf, 0x00); // blink 0 aan, 0x10 is glob uit wr(PE_ADD, 0x6, 0x00); // input en output config. wr(PE_ADD, 0x7, 0x00); // oninterresante getallen, afblijven!! wr(PE_ADD, 0x2, 0xff); wr(PE_ADD, 0x3, 0xff); wr(PE_ADD, 0xe, 0x00); // config bit static output delay(200); Serial.println("-------------------------------------"); Serial.println(); for(byte a = 0x01; a>0x00;a++) { for(byte b = 0x01; b>0x00;b++) { Serial.println("Try"); Serial.println(a); Serial.println(b); delay(450); wr(PE_ADD, 0xf, a); // blink 0 aan, 0x10 is glob uit wr(PE_ADD, 0xe, b); // config bit static output delay(100); for(int i = 0x10; i < 0x18; i++) { wr(PE_ADD, i, 0x00); } delay(450); for(int i = 0x10; i < 0x18; i++) { wr(PE_ADD, i, 0xFF); } } } } void loop() { /* Serial.println("Pins HIGH schalten"); for(int i = 0x10; i < 0x18; i++) { wr(PE_ADD, i, 0x00); } delay(1000); Serial.println("Pins LOW schalten"); for(int i = 0x10; i < 0x18; i++) { wr(PE_ADD, i, 0xFF); } delay(1000); */ } void wr(byte add, byte reg, byte data) { Wire.beginTransmission(add); byte reg_write = Wire.write(reg); byte data_write = Wire.write(data); byte error = Wire.endTransmission(true); }