Intro to Phy Comp 6
Serial Communication Agreements
Three things to check for it to happen
- The rate at which data is sent and read (9600, etc)
- The voltage levels representing a 1 or a 0 bit
- The meaning of those voltage levels; 1 = hight & 0 = low or the other way around?
LAB1: Serial Terminal Programs (Link)
*Only one monitor at a time
Reading Adafruit LIS3DH Triple-Axis Accelerometer Breakout
Serial monitor
Cool term
Terminal
- Get a list of my serial ports by typing
ls -1 /dev/cu.* - See what the Arduino is sending out, type
cat /dev/cu.myPortName
*make sure to have space after “cat”
Adafruit LIS3DH
- Three-axis sensing
- Both I2C (2 possible addresses) and SPI interface options
- Tap, Double-tap, orientation & freefall detection
- Adafruit_LIS3DH.h library required, downloaded directly from Arduino manage library
- LIS3DSH.h <-- this library doesn't work. (1, 2)
1
At P5.js, add
2
At P5.js/ index.html, add
3
At P5.js/ sketch.js, add
scripts enabling the communication
Reading serial data as a binary VS string
Serial.write();
Sensor value: undefined
happened while doing the Serial.write with the value going over 255
Serial.println();
Serial.println();
With Serial.write(); value abled to send is limited to 0-255, which is less sensitive than reading values btwn 0-1023. However, the values will be printed in ASCII-encoded numeric string.