1234567891011121314151617181920212223242526272829303132333435 |
- #include <Wire.h>
- #define AD_adress1 0x2c
- #define AD_adress2 0x2f
- #define AD_pot1 0x00
- #define AD_pot2 0x80
- int potValue[4];
- int potValueUpdate[4];
- byte potAdress[][2] = { {AD_adress1, AD_pot1},
- {AD_adress1, AD_pot2},
- {AD_adress2, AD_pot1},
- {AD_adress2, AD_pot2}, };
- void setup_AD5242() {
- Wire.begin(); // join i2c bus (address optional for master)
- Serial.begin(115200);
- }
- void handle_AD5242() {
- for (int i ; i++ ; i<4){
- if (potValue[i] != potValueUpdate[i]) {
- potValue[i] = potValueUpdate[i];
- Wire.beginTransmission(potAdress[i][1]);
- Wire.write(potAdress[i][2]);
- Wire.write(potValue[i]);
- Wire.endTransmission();
- Serial.print(potAdress[i][1] + " : ");
- Serial.println(potAdress[i][2]);
- }
- }
-
- }
|