Lab: Intro to Asynchronous Serial Communications
I did not find any ADXL335 accelerometer module in my toolbox, so I used a GY-521 instead. After checking the datasheet, I figured out this one was a part of MPU6050, which contains both a 3-Axis Gyroscope and a 3-Axis accelerometer.
The GY-521 breakout has eight pins:
- VCC (The breakout board has a voltage regulator. Therefore, you can connect the board to 3.3V and 5V sources.)
- SCL (Serial Clock Line of the I2C protocol.)
- SDA (Serial Data Line of the I2C protocol.)
- XDA (Auxiliary data => I2C master serial data for connecting the module to external sensors.)
- XCL (Auxiliary clock => I2C master serial clock for connecting the module to external sensors.)
- AD0 (If this pin is LOW, the I2C address of the board will be 0x68. Otherwise, if the pin is HIGH, the address will be 0x69.)
- INT (Interrupt digital output)
Q: I tried the code provided, the raw binary value turned out to be some random words. I’m not sure if that happened due to the different protocols I’ve used. And also I did not understand why the analog value varies, I didn’t move it or touch it, what caused the difference.
After asking Jeff after class, I understand that this protocol is a I2C part, which follows a different rule from the part shown in this lab. So used potentiometer instead, then I got the result easily.
It’s quite interesting to finally connect Arduino with p5.js, I followed the tutorial and used potentiometer to send data to p5. It’s a little bit tricky to set the p5.serialcontrol on and off, to upload files then link it to p5. I got to unerstand how these two use different language to communicate, we need to translate it when send data in and out.