@@ -7,16 +7,58 @@ uint8_t led = 6;
77uint8_t pot = A0;
88uint8_t mic = A2;
99uint8_t light = A3;
10+
11+ // From https://playground.arduino.cc/Main/I2cScanner/
12+ // learn more about I2C here
13+ // https://www.seeedstudio.com/blog/2019/09/25/uart-vs-i2c-vs-spi-communication-protocols-and-uses/
14+ // Scanner from https://github.com/RobTillaart/Arduino/blob/master/sketches/MultiSpeedI2CScanner/MultiSpeedI2CScanner.ino
15+ // 30038 25 0x19 V V V V V V V V
16+ // 30133 60 0x3C V V V V V V V V
17+ // 30296 119 0x77 V V V V V V V V
18+ void i2c_scan () {
19+ uint8_t error, address, nDevices;
20+
21+ Wire.begin ();
22+ Serial.println (" Scanning..." );
23+
24+ nDevices = 0 ;
25+ for (address = 1 ; address < 127 ; address++ )
26+ {
27+ // Serial.println("I2C scan");
28+ // The i2c_scanner uses the return value of
29+ // the Write.endTransmisstion to see if
30+ // a device did acknowledge to the address.
31+ Wire.beginTransmission (address);
32+ error = Wire.endTransmission ();
33+
34+ if (error == 0 )
35+ {
36+ Serial.print (" I2C device found at address 0x" );
37+ if (address<16 )
38+ Serial.print (" 0" );
39+ Serial.print (address,HEX);
40+ Serial.println (" !" );
41+
42+ nDevices++;
43+ }
44+ else if (error==4 )
45+ {
46+ Serial.print (" Unknown error at address 0x" );
47+ if (address<16 )
48+ Serial.print (" 0" );
49+ Serial.println (address,HEX);
50+ }
51+ }
52+ if (nDevices == 0 )
53+ Serial.println (" No I2C devices found\n " );
54+ else
55+ Serial.println (" done\n " );
56+ }
1057
1158void setup () {
12- #if 0
13- // Accelerometer and Oled both share the same I2C address
14- // both cannot be used at the same time, unless you solder
15- // across the I2C address solder pads on the Oled module
16- Accelerometer.begin();
17- // Same problem with pressure sensor
18- Pressure.begin();
19- #endif
59+ Serial.begin (115200 );
60+ // Running scan stops the OLED from working
61+ // i2c_scan();
2062
2163 pinMode (mic , INPUT);
2264 pinMode (light , INPUT);
@@ -29,6 +71,10 @@ void setup() {
2971
3072 Oled.begin ();
3173 Oled.setFlipMode (true );
74+
75+ // Enabling any of those 2 stops the OLED from working
76+ // Accelerometer.begin();
77+ // Pressure.begin();
3278}
3379
3480void loop () {
0 commit comments