Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#include <Adafruit_CircuitPlayground.h>
//Declare Pins
int analogPin= 11;
int analogValue;
// For final output
int beakPressure;
// Variables for Y
float prevY;
float currentY;
float accelerationY;
float tiltY;
//Variables for X
float prevX;
float currentX;
float accelerationX;
float tiltX;
void setup() {
void loop() {
prevY=currentY; // get the value of Y from previous Loop
currentY=CircuitPlayground.motionY(); //set current Y to a new Y value from tha accelerometer
accelerationY= (currentY-prevY); //get the acceleration
prevX=currentX; //get the value ofX from previous Loop
currentX=CircuitPlayground.motionX(); //set current X to a new X value from tha accelerometer
accelerationX= (currentX-prevX);// get the acceleration
analogValue = analogRead(analogPin);// declare Pressure sensor
beakPressure= analogValue+ 100;
// make sure the value for the intervals is always a positive value
CircuitPlayground.playTone(beakPressure, tiltY);// Sound output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment