[{"data":1,"prerenderedAt":78},["ShallowReactive",2],{"example-page-uno-tilt":3},{"id":4,"info":5,"parts":6,"wired":16,"refs":17,"nets":18,"moreNets":72,"code":73},"uno-tilt","The MPU-6050 motion sensor (GY-521, I²C) measures gravity; a 2×2 \"ball\" rolls to the lowest point on the 8×8 LED matrix (MAX7219, LedControl library). Set the tilt with acceleration X \u002F Y in the inspector (for example 0.4 g), even while the simulation runs.",[7,10,12,14],[8,9],"arduino_uno",1,[11,9],"max7219_matrix",[13,9],"mpu6050",[15,9],"vdc",false,{"A1":8,"DS1":11,"U2":13,"V1":15},[19,32,41,47,53,60,66],{"name":20,"pins":21},"0",[22,25,27,29],[23,24],"A1","GND",[26,24],"DS1",[28,24],"U2",[30,31],"V1","−",{"name":33,"pins":34},"5V",[35,36,38,39],[23,33],[26,37],"VCC",[28,37],[30,40],"+",{"name":42,"pins":43},"CS",[44,46],[23,45],"~D10\u002FSS",[26,42],{"name":48,"pins":49},"DIN",[50,52],[23,51],"D12\u002FMISO",[26,48],{"name":54,"pins":55},"MCLK",[56,58],[23,57],"~D11\u002FMOSI",[26,59],"CLK",{"name":61,"pins":62},"SCL",[63,65],[23,64],"A5\u002FSCL",[28,61],{"name":67,"pins":68},"SDA",[69,71],[23,70],"A4\u002FSDA",[28,67],0,{"file":74,"lang":75,"text":76,"lines":77,"more":16},"sketch.ino","cpp","\u002F\u002F MPU6050 (I²C, A4\u002FA5) measures the tilt, a 2×2 \"ball\" rolls on the 8×8 matrix (MAX7219:\n\u002F\u002F DIN D12, CLK D11, CS D10) to wherever it goes downhill\n#include \u003CAdafruit_MPU6050.h>\n#include \u003CLedControl.h>\n\nAdafruit_MPU6050 mpu;\nLedControl matrix(12, 11, 10, 1);\n\nvoid setup() {\n  Serial.begin(115200);\n  matrix.shutdown(0, false);       \u002F\u002F the MAX7219 is in shutdown after power-on\n  matrix.setIntensity(0, 6);\n  matrix.clearDisplay(0);\n  if (!mpu.begin()) Serial.println(F(\"MPU6050 missing\"));\n  mpu.setAccelerometerRange(MPU6050_RANGE_2_G);\n}\n\nvoid loop() {\n  sensors_event_t a, g, t;\n  mpu.getEvent(&a, &g, &t);\n  int x = constrain((int)round(3 + a.acceleration.x \u002F 9.81 * 6), 0, 6);\n  int y = constrain((int)round(3 - a.acceleration.y \u002F 9.81 * 6), 0, 6);\n  for (int row = 0; row \u003C 8; row++) matrix.setRow(0, row, (row == y || row == y + 1) ? (0xC0 >> x) : 0);\n  Serial.print(F(\"ax \")); Serial.print(a.acceleration.x, 2); Serial.print(F(\"  ay \")); Serial.println(a.acceleration.y, 2);\n  delay(50);\n}",26,1796304400904]