Sensor Applications
Tilt-Based Interaction
Objective: Use the onboard Gyroscope (LSM6DS33) to detect tilting in different directions and trigger corresponding actions.
Read acceleration values.
Define threshold values to detect tilts in the X and Y directions.
Print messages based on tilt direction:
Left tilt → "Tilted Left!"
Right tilt → "Tilted Right!"
Forward tilt → "Tilted Forward!"
Backward tilt → "Tilted Backward!"
Instead of printing messages, map tilt direction to onboard NeoPixel colours.
Gesture-Based Control with APDS9960
Objective: Use the gesture sensor (APDS9960) to recognize hand movements and trigger different actions.
Enable gesture detection.
Read gesture inputs.
Print detected gestures:
Left swipe → "Left Gesture Detected!"
Right swipe → "Right Gesture Detected!"
Up swipe → "Up Gesture Detected!"
Down swipe → "Down Gesture Detected!"
Digital Compass with Visual Feedback
Objective: Use the magnetometer (LIS3MDL) to determine orientation and display cardinal directions.
Read magnetometer data.
Compute heading using
math.atan2(mag_y, mag_x) * (180 / math.pi)
.Print the corresponding cardinal direction:
0° to 45° → "North"
45° to 135° → "East"
135° to 225° → "South"
225° to 315° → "West"
If using a NeoPixel, change its colour based on the direction.
Add a small hysteresis to avoid flickering between directions.
Silent Clap Detector (Sound Level Spike Detection)
Objective: Detect sudden increases in microphone sound level and print a message when a "clap" is detected.
Read microphone RMS values using
normalized_rms(samples)
.Set a threshold for detecting a sharp increase in amplitude.
Print "Clap detected!" when the threshold is exceeded.
Implement a double clap detector by checking if two claps occur within 1 second.
Vibrations Detector using Accelerometer
Objective: Use the accelerometer to detect a strong tap or knock on the board.
Continuously read acceleration values.
Detect sudden spikes in acceleration above a defined threshold.
Print "Knock detected!" when a knock is detected.
Count and display the number of knocks detected within a given time frame.
Last updated