{"id":551,"date":"2022-01-05T19:35:17","date_gmt":"2022-01-05T18:35:17","guid":{"rendered":"https:\/\/spotonfun.pl\/?p=488"},"modified":"2022-01-13T16:53:59","modified_gmt":"2022-01-13T15:53:59","slug":"arduino-project-biofeedback-device-learning-meditation-part-2-gyroscope-connection","status":"publish","type":"post","link":"https:\/\/spotonfun.pl\/index.php\/en\/2022\/01\/05\/arduino-project-biofeedback-device-learning-meditation-part-2-gyroscope-connection\/","title":{"rendered":"Arduino Project &#8211; Biofeedback Device &#8211; Learning Meditation &#8211; Part 2 &#8211; Gyroscope Connection"},"content":{"rendered":"<p>If you are here for the first time, I encourage you to read <a rel=\"noreferrer noopener\" href=\"https:\/\/spotonfun.pl\/index.php\/2021\/12\/28\/projekt-arduino-urzadzenie-do-biofeedbacku-nauka-medytacji-czesc-1\/\" data-type=\"URL\" data-id=\"https:\/\/spotonfun.pl\/index.php\/2021\/12\/28\/projekt-arduino-urzadzenie-do-biofeedbacku-nauka-medytacji-czesc-1\/\" target=\"_blank\">the previous part<\/a> &#8211; which is a kind of introduction &#8211; a description of the project and its genesis.<\/p><p>Since I have to wait for my Arduino nano, I decided to start with Arduino Uno, which &#8222;I have in stock&#8221;. Besides, it&#8217;s bigger and easier to prototype on it and connect all those magic cables \ud83d\ude42<\/p><style>.wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1, .wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1[data-kb-block=\"kb-adv-heading_203cce-c1\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1[data-kb-block=\"kb-adv-heading_203cce-c1\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_203cce-c1[data-kb-block=\"kb-adv-heading_203cce-c1\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_203cce-c1 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_203cce-c1\">The beginning &#8211; in search of &#8222;how to do it&#8221; \ud83d\ude42  <\/h2><p>Documentation for the GY-521 is available <a rel=\"noreferrer noopener\" href=\"https:\/\/idoc.pub\/documents\/mpu-6050-gy-521-datasheet-6nq800owrpnw\" target=\"_blank\">here.<\/a> <\/p><p>Because I have not had contact with electronic documentation for a long time, I decided to look for more &#8222;human-understandable&#8221; descriptions. Fortunately, the Internet came to the rescue and I quickly found how to connect everything together. Google heavily in use :). Interestingly, in addition to the scheme, I also found programs to operate the module &#8211; but more on that in a moment.<\/p><style>.wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70, .wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70[data-kb-block=\"kb-adv-heading_bb827f-70\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70[data-kb-block=\"kb-adv-heading_bb827f-70\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_bb827f-70[data-kb-block=\"kb-adv-heading_bb827f-70\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_bb827f-70 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_bb827f-70\">We connect the cables<\/h2><p>This is the connection diagram of the GY-521 module with Arduino:<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/GY-521-arduino-polaczenie-1024x1024.png\" alt=\"\" class=\"wp-image-508\"\/><figcaption>Diagram of connecting the GY-521 gyroscope (MPU6050) to Arduino Uno<\/figcaption><\/figure><p>And this is how it looks in my set-up &#8211; using the prototype board:<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/20211228_183547-1024x768.jpg\" alt=\"\" class=\"wp-image-510\"\/><\/figure><style>.wp-block-kadence-column.kb-section-dir-horizontal > .kt-inside-inner-col > #kt-info-box_40afc9-39 .kt-blocks-info-box-link-wrap{max-width:unset;}#kt-info-box_40afc9-39 .kt-blocks-info-box-link-wrap{border-color:rgba(43, 108, 176, 0.17);border-radius:21px;border-top-width:5px;border-right-width:5px;border-bottom-width:5px;border-left-width:5px;background:#ffffff;padding-top:24px;padding-right:24px;padding-bottom:24px;padding-left:24px;margin-top:50px;}#kt-info-box_40afc9-39 .kt-blocks-info-box-link-wrap:hover{background:#ffffff;}#kt-info-box_40afc9-39.wp-block-kadence-infobox{max-width:100%;}#kt-info-box_40afc9-39 .kadence-info-box-image-inner-intrisic-container{max-width:100px;}#kt-info-box_40afc9-39 .kadence-info-box-image-inner-intrisic-container .kadence-info-box-image-intrisic{padding-bottom:100%;width:45px;height:0px;max-width:100%;}#kt-info-box_40afc9-39 .kadence-info-box-icon-container .kt-info-svg-icon, #kt-info-box_40afc9-39 .kt-info-svg-icon-flip, #kt-info-box_40afc9-39 .kt-blocks-info-box-number{font-size:50px;}#kt-info-box_40afc9-39 .kt-blocks-info-box-media{color:#444444;background:#ffffff;border-color:#eeeeee;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}#kt-info-box_40afc9-39 .kt-blocks-info-box-media-container{margin-top:-45px;margin-right:0px;margin-bottom:20px;margin-left:0px;}#kt-info-box_40afc9-39 .kt-blocks-info-box-link-wrap:hover .kt-blocks-info-box-media{color:#444444;background:#ffffff;border-color:#eeeeee;}#kt-info-box_40afc9-39 .kt-infobox-textcontent h4.kt-blocks-info-box-title{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:5px;margin-right:0px;margin-bottom:10px;margin-left:0px;}#kt-info-box_40afc9-39 .kt-blocks-info-box-learnmore{background:transparent;border-width:0px 0px 0px 0px;padding-top:4px;padding-right:8px;padding-bottom:4px;padding-left:8px;margin-top:10px;margin-right:0px;margin-bottom:10px;margin-left:0px;}<\/style>\n<div id=\"kt-info-box_40afc9-39\" class=\"wp-block-kadence-infobox\"><div class=\"kt-blocks-info-box-link-wrap kt-blocks-info-box-media-align-top kt-info-halign-left\"><div class=\"kt-blocks-info-box-media-container\"><div class=\"kt-blocks-info-box-media kt-info-media-animate-none\"><div class=\"kadence-info-box-image-inner-intrisic-container\"><div class=\"kadence-info-box-image-intrisic kt-info-animate-none\"><div class=\"kadence-info-box-image-inner-intrisic\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/info_icon.png\" alt=\"\" width=\"45\" height=\"45\" class=\"kt-info-box-image wp-image-481\"\/><\/div><\/div><\/div><\/div><\/div><div class=\"kt-infobox-textcontent\"><h4 class=\"kt-blocks-info-box-title\">Note on the prototype board<\/h4><p class=\"kt-blocks-info-box-text\">Since I hadn&#8217;t done anything with Arduino before, I didn&#8217;t really know how the prototype board works. I more or less guessed it, but I at the end I checked with a electonic-meter which elements are connected to each other and this confirmed my guess &#8211; rows are connected with each other, e.g. in my case &#8222;f-g-h-i-j&#8221; is connected in each row, so when I inserted my gyroscope module into the &#8222;j&#8221; column, I could plug the cables into the appropriate rows of pins in the &#8222;g&#8221; column. In addition, the entire + column is short (I used it as a power source &#8222;+V&#8221;) and similarly the column &#8222;-&#8221; (I used it as a mass &#8222;GND&#8221;)<\/p><\/div><\/div><\/div><style>.wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a, .wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a[data-kb-block=\"kb-adv-heading_af6869-8a\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a[data-kb-block=\"kb-adv-heading_af6869-8a\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_af6869-8a[data-kb-block=\"kb-adv-heading_af6869-8a\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_af6869-8a wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_af6869-8a\">It&#8217;s time for a USB data collection program<\/h2><p>Here I do not darken. I had no idea how to start programming Arduino (even though I can program as such). That&#8217;s why I used the ready-made, and then analyzed it with the understanding of \ud83d\ude42 and A little changed what he writes.<\/p><p>But before the program, then you need to install on your computer the Arduino IDE environment &#8211; it is free and you can download it <a rel=\"noreferrer noopener\" href=\"https:\/\/www.arduino.cc\/en\/software\" target=\"_blank\">here<\/a>. When launched, it looks more or less like the screenshot below. I marked two points there &#8211; the upper right corner is the button to open the &#8222;Serial Port Monitor&#8221;, while in the lower right corner you can see the connected device (and the port on which you connected).<\/p><figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/ArduinoIDE.png\" alt=\"\" class=\"wp-image-518\"\/><figcaption>ArduinoIDE after installation<\/figcaption><\/figure><p>Now all you need is the program. Mine, after altering <a rel=\"noreferrer noopener\" href=\"https:\/\/howtomechatronics.com\/tutorials\/arduino\/arduino-and-mpu6050-accelerometer-and-gyroscope-tutorial\/\" target=\"_blank\">the original <\/a>looks like this:<\/p><pre title=\"Gyroscope support\" class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp line-numbers\">&lt;Wire.h&gt;#include\nconst int MPU_ADDR=0x68;\nint16_t AcX, AcY, AcZ; acc raw date\nint16_t GyX, GyY, GyZ; gyro raw date\nTmp int16_t; temperature date\n\nfor calc. roll, pitch and yaw\nfloat accAngleX, accAngleY, gyroAngleX, gyroAngleY, gyroAngleZ;\nfloat elapsedTime, currentTime, previousTime;\nfloat rollZ, pitchX, yawY; Z- looking direction, Y- up\/down, X-horizontal through ears\nfloat rotZ, rotX, roty; Z- looking direction, Y- up\/down, X-horizontal through ears\n\nvarables for calc. error\nfloat AcXerr, AcYerr, AcZerr; acc error\nfloat GyXerr, GyYerr, GyZerr; gyro error\nint c;\n\nchar tmp_str [7] ; \/\/ temporary variable used in convert function\nchar* convert_int16_to_str(int16_t i) { \/\/ convert int16 to string - for debug window\n  sprintf(tmp_str, \"%6d\", i);\n  return tmp_str;  \n}\n\nvoid setup() {\n\nstart transmission\n  Serial.begin(9600);\n  Serial.println(\"setup..\");&lt;\/Wire.h&gt;\n  \n  put your setup code here, to run once:\n  Wire.begin();\n  Wire.beginTransmission(MPU_ADDR); Begins a transmission to the I2C slave (GY-521 board)\n  Wire.write(0x6B); PWR_MGMT_1 register\n  Wire.write(0); set to zero (wakes up the MPU-6050)\n  Wire.endTransmission(true);\n\ndo below at the beginning to check the errors that need to go to loop() equations\n  comment everything from the loop to have clear output\n  calculate_IMU_error(); zero!! GyXerr = 0.12, GyYerr=1.30, GyZerr=0.32;\n  delay(500);  \n}\n\nvoid loop() {\n  put your main code here, to run repeatedly:\n  Wire.beginTransmission(MPU_ADDR);\n  Wire.write(0x3B); starting with reg. 0x38 (ACCEL_XOUT_H) [MPU-6000 and MPU-6050 Register Map and Descriptions Revision 4.2, p.40]\n  Wire.endTransmission(false); the parameter indicates that the Arduino will send a restart. As a result, the connection is kept active.\n  Wire.requestFrom(MPU_ADDR, 7*2, true); request a total of 7 * 2 = 14 registers\n  \"Wire.read() &lt;8 | Wire.read();\" means two registers are read and stored in the same variable\n  AcX = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)\n  AcY = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)\n  AcZ = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)\n  Tmp = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)\n  GyX = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)\n  GyY = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)\n  GyZ = Wire.read() &lt;8 | Wire.read(); \/\/ reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)\n\n\n  \/\/clclulate useful data\n  previousTime = currentTime;        \/\/ Previous time is stored before the actual time read\n  currentTime = millis();            \/\/ Current time actual time read\n  elapsedTime = (currentTime - previousTime) \/ 1000; \/\/ Divide by 1000 to get seconds\n\n  \/\/ Correct the outputs with the calculated error values\n  GyX = GyX + 0.1; \/\/ GyroErrorX ~(0.12)\n  GyY = GyY + 1.35; \/\/ GyroErrorY ~(1.30)\n  GyZ = GyZ + 0.32; \/\/ GyroErrorZ ~ (0.32)\n  \n  accAngleX = (atan(AcY \/ sqrt(pow(AcX, 2) + pow(AcZ, 2))) * 180 \/ PI) - 0.0; \/\/ AccErrorX ~(0.0) See the calculate_IMU_error()custom function for more details\n  accAngleY = (atan(-1 * AcX \/ sqrt(pow(AcY, 2) + pow(AcZ, 2))) * 180 \/ PI) + 0.0; \/\/ AccErrorY ~(0.0)\n  gyroAngleX = gyroAngleX + GyX * elapsedTime; \/\/ deg\/s * s = deg\n  gyroAngleY = gyroAngleY + GyY * elapsedTime;\n  \n  \/\/float rotZ, rotX, rotY; \/\/ Z- looking direction, Y- up\/down, X-horizontal through ears\n  rotY =  (rotY + GyZ * elapsedTime);\n  \/\/ Complementary filter - combine acceleromter and gyro angle values\n  rotZ = (0.96 * gyroAngleX + 0.04 * accAngleX) ;\n  rotX = (0.96 * gyroAngleY + 0.04 * accAngleY) ;\n\n\n\n  \n  \/\/ print data\n  \n  Serial.print(\"   AcX |    AcY |    AcZ | n\"); \n  Serial.print(convert_int16_to_str(AcX)); Serial.print(\" | \");\n  Serial.print(convert_int16_to_str(AcY)); Serial.print(\" | \");\n  Serial.print(convert_int16_to_str(AcZ)); Serial.print(\" | n\");\n  \/\/ the following equation was taken from the documentation  [MPU-6000\/MPU-6050 Register Map and Description, p.30]\n  Serial.print(\"---------------------------n\");\n  Serial.print(\" GyX |    GyY |    GyZ | n\"); \n  Serial.print(convert_int16_to_str(GyX)); Serial.print(\" | \");\n  Serial.print(convert_int16_to_str(GyY)); Serial.print(\" | \");\n  Serial.print(convert_int16_to_str(GyZ)); Serial.print(\" | n\");\n  Serial.print(\"---------------------------n\");\n  Serial.print(\"Tmp = \"); Serial.print(Tmp\/340.00+36.53); Serial.print(\"n\");\n  Serial.print(\"---------------------------n\");\n  Serial.print(\" RotX |   RotY |   RotZ | n\"); \n  Serial.print(rotX); Serial.print(\" | \");\n  Serial.print(rotY); Serial.print(\" | \");\n  Serial.print(rotZ); Serial.print(\" | n\");\n  Serial.print(\"---------------------------n\");\n\nSerial.print(\"n\");\n \ndelay\n  delay(20); \n}\n\nvoid calculate_IMU_error() {\n  We can call this funtion in the setup section to calculate the accelerometer and gyro data error. From here we will get the error values used in the above equations printed on the Serial Monitor.\n  Note that we should place the IMU flat in order to get the proper values, so that we then can the correct values\n  Read accelerometer values 200 times\n  const int NUM_TRIES = 200;\n  while (c &lt; NUM_TRIES) {\n    Wire.beginTransmission(MPU_ADDR);\n    Wire.write(0x3B);\n    Wire.endTransmission(false);\n    Wire.requestFrom(MPU_ADDR, 3*2, true);\n    AcX = (Wire.read() &lt; 8 | Wire.read()) \/ 16384.0 ;\n    AcY = (Wire.read() &lt; 8 | Wire.read()) \/ 16384.0 ;\n    AcZ = (Wire.read() &lt; 8 | Wire.read()) \/ 16384.0 ;\n    \/\/ Sum all readings\n    AcXerr = AcXerr + ((atan((AcY) \/ sqrt(pow((AcX), 2) + pow((AcZ), 2))) * 180 \/ PI));\n    AcYerr = AcYerr + ((atan(-1 * (AcX) \/ sqrt(pow((AcY), 2) + pow((AcZ), 2))) * 180 \/ PI));\n    c++;\n  }\n  \/\/Divide the sum by 200 to get the error value\n  AcXerr = AcXerr \/ NUM_TRIES;\n  AcYerr = AcYerr \/ NUM_TRIES;\n  c = 0;\n  \/\/ Read gyro values 200 times\n  while (c &lt; NUM_TRIES) {\n    Wire.beginTransmission(MPU_ADDR);\n    Wire.write(0x43);\n    Wire.endTransmission(false);\n    Wire.requestFrom(MPU_ADDR, 3*2, true);\n    GyX = Wire.read() &lt; 8 | Wire.read();\n    GyY = Wire.read() &lt; 8 | Wire.read();\n    GyZ = Wire.read() &lt; 8 | Wire.read();\n    \/\/ Sum all readings\n    GyXerr = GyXerr + (GyX \/ 131.0);\n    GyYerr = GyYerr + (GyY \/ 131.0);\n    GyZerr = GyZerr + (GyZ \/ 131.0);\n    c++;\n  }\n  \/\/Divide the sum by 200 to get the error value\n  GyXerr = GyXerr \/ NUM_TRIES;\n  GyYerr = GyYerr \/ NUM_TRIES;\n  GyZerr = GyZerr \/ NUM_TRIES;\n  \/\/ Print the error values on the Serial Monitor\n  Serial.print(\"AcXerr: \");\n  Serial.println(AcXerr);\n  Serial.print(\"AcYerr: \");\n  Serial.println(AcYerr);\n  Serial.print(\"GyXerr: \");\n  Serial.println(GyXerr);\n  Serial.print(\"GyYerr: \");\n  Serial.println(GyYerr);\n  Serial.print(\"GyZerr: \");\n  Serial.println(GyZerr);\n}<\/code><\/pre><p>And voual&#8217;a! I have readings!<\/p><p><strong>Note to the readings:<\/strong> before I started the main program, I put the sensor still and fired only the calculate_IMU_error() function. It collects 200 readings (this can be changed by setting the value of NUM_TRIES), averages them and shows the result &#8211; this is really a sensor error (i.e. kind of a calibration). This error should be included in the program in the calculations:<\/p><pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp line-numbers\">GyX = GyX + 0.1; GyroErrorX ~(0.12)\nGyY = GyY + 1.35; GyroErrorY ~(1.30)\nGyZ = GyZ + 0.32; GyroErrorZ ~ (0.32)\n\naccAngleX = (atan(AcY \/ sqrt(pow(AcX, 2) + pow(AcZ, 2))) * 180 \/ PI) - 0.0; See the calculate_IMU_error()custom function for more details\n\naccAngleY = (atan(-1 * AcX \/ sqrt(pow(AcY, 2) + pow(AcZ, 2))) * 180 \/ PI) + 0.0; AccErrorY ~(0.0)\n\n<\/code><\/pre><p><\/p><figure class=\"wp-block-video\"><video controls src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/20211228_183621.mp4\"><\/video><figcaption>Readings from GY-251 (MPU6050)<\/figcaption><\/figure><style>.wp-block-kadence-column.kb-section-dir-horizontal > .kt-inside-inner-col > #kt-info-box_9e536f-31 .kt-blocks-info-box-link-wrap{max-width:unset;}#kt-info-box_9e536f-31 .kt-blocks-info-box-link-wrap{border-color:rgba(43, 108, 176, 0.17);border-radius:21px;border-top-width:5px;border-right-width:5px;border-bottom-width:5px;border-left-width:5px;background:#ffffff;padding-top:24px;padding-right:24px;padding-bottom:24px;padding-left:24px;margin-top:50px;}#kt-info-box_9e536f-31 .kt-blocks-info-box-link-wrap:hover{background:#ffffff;}#kt-info-box_9e536f-31.wp-block-kadence-infobox{max-width:100%;}#kt-info-box_9e536f-31 .kadence-info-box-image-inner-intrisic-container{max-width:100px;}#kt-info-box_9e536f-31 .kadence-info-box-image-inner-intrisic-container .kadence-info-box-image-intrisic{padding-bottom:100%;width:45px;height:0px;max-width:100%;}#kt-info-box_9e536f-31 .kadence-info-box-icon-container .kt-info-svg-icon, #kt-info-box_9e536f-31 .kt-info-svg-icon-flip, #kt-info-box_9e536f-31 .kt-blocks-info-box-number{font-size:50px;}#kt-info-box_9e536f-31 .kt-blocks-info-box-media{color:#444444;background:#ffffff;border-color:#eeeeee;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}#kt-info-box_9e536f-31 .kt-blocks-info-box-media-container{margin-top:-45px;margin-right:0px;margin-bottom:20px;margin-left:0px;}#kt-info-box_9e536f-31 .kt-blocks-info-box-link-wrap:hover .kt-blocks-info-box-media{color:#444444;background:#ffffff;border-color:#eeeeee;}#kt-info-box_9e536f-31 .kt-infobox-textcontent h4.kt-blocks-info-box-title{padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:5px;margin-right:0px;margin-bottom:10px;margin-left:0px;}#kt-info-box_9e536f-31 .kt-blocks-info-box-learnmore{background:transparent;border-width:0px 0px 0px 0px;padding-top:4px;padding-right:8px;padding-bottom:4px;padding-left:8px;margin-top:10px;margin-right:0px;margin-bottom:10px;margin-left:0px;}<\/style>\n<div id=\"kt-info-box_9e536f-31\" class=\"wp-block-kadence-infobox\"><div class=\"kt-blocks-info-box-link-wrap kt-blocks-info-box-media-align-top kt-info-halign-left\"><div class=\"kt-blocks-info-box-media-container\"><div class=\"kt-blocks-info-box-media kt-info-media-animate-none\"><div class=\"kadence-info-box-image-inner-intrisic-container\"><div class=\"kadence-info-box-image-intrisic kt-info-animate-none\"><div class=\"kadence-info-box-image-inner-intrisic\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/spotonfun.pl\/wp-content\/uploads\/2021\/12\/info_icon.png\" alt=\"\" width=\"45\" height=\"45\" class=\"kt-info-box-image wp-image-481\"\/><\/div><\/div><\/div><\/div><\/div><div class=\"kt-infobox-textcontent\"><h4 class=\"kt-blocks-info-box-title\">Note on Arduino IDE and VS Code<\/h4><p class=\"kt-blocks-info-box-text\">I&#8217;ve been writing most of my programs in Visual Studio Code lately, and I really like this IDE. That&#8217;s why I was looking for how to use my favorite environment for Arduino &#8211; and guess what &#8211; I found instructions <a rel=\"noreferrer noopener\" href=\"https:\/\/maker.pro\/arduino\/tutorial\/how-to-use-visual-studio-code-for-arduino\" target=\"_blank\">here<\/a> (English version). But beware! This will not work if you have installed the Arduino IDE from the Microsoft store (under Windows of course). I had it and I had to uninstall it from the store, download the version for Win7+, install it and then it worked (you still have to specify the path the Arduino IDE installation in the configuration of the board &#8211; this was the problem with the application from the MS store &#8211; or maybe you know how to find the path to the apps from the Microsoft store? Write in the comments! <br\/><br\/><strong>UPDATE<\/strong>: Unfortunately, it turned out that I could not force the &#8222;Serial monitor&#8221; to show data on a regular basis and eventually gave up VSCode in favor of Arduino IDE 2.0.0-rec3, which offers syntax completion and is quite similar to VSCode.<\/p><\/div><\/div><\/div><style>.wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd, .wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd[data-kb-block=\"kb-adv-heading_6ce522-bd\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd[data-kb-block=\"kb-adv-heading_6ce522-bd\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading_6ce522-bd[data-kb-block=\"kb-adv-heading_6ce522-bd\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading_6ce522-bd wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading_6ce522-bd\">Source:<\/h2><ol class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/idoc.pub\/documents\/mpu-6050-gy-521-datasheet-6nq800owrpnw\" target=\"_blank\">Documentation of the GY-521 module<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.arduino.cc\/en\/software\" target=\"_blank\">Arduino IDE<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/howtomechatronics.com\/tutorials\/arduino\/arduino-and-mpu6050-accelerometer-and-gyroscope-tutorial\/\" target=\"_blank\">Program for collecting data from the module with error correction<\/a><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>If you are here for the first time, I encourage you to read the previous part &#8211; which is a kind of introduction &#8211; a description of the project and its genesis. Since I have to wait for my Arduino nano, I decided to start with Arduino Uno, which &#8222;I have in stock&#8221;. Besides, it&#8217;s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-551","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii"],"_links":{"self":[{"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/posts\/551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/comments?post=551"}],"version-history":[{"count":1,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/media?parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/categories?post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spotonfun.pl\/index.php\/wp-json\/wp\/v2\/tags?post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}