Interaction Beyond Screens (Part 4)

Last week we were looking to connect the Arduino with android to play music, which was not possible without a receptor. On doing research, we discovered an app ‘Blue Act’ which works on communications between the android and Arduino.

You can find it here:

We started finding ways to make the arduino and Blue Act communication seamless. We worked on Arduino codes to send the keywords to start and stop playing music on android.

We were concentrating on forward action so we chose to take the z axis as the axis for sensing the motion of the user. So we debugged the code and changed it accordingly. Final code is given below:

// these constants describe the pins. They won't change:
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A0; // x-axis of the accelerometer
const int ypin = A1; // y-axis
const int zpin = A2; // z-axis (only on 3-axis models)
boolean calibrated=false; // When accelerometer is calibrated - changes to true
boolean moveDetected=false; // When motion is detected - changes to true
int threshold = 330;
int zVal, zMin, zMax;

void setup() {
// initialize the serial communications:

// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);

void loop() {
// print the sensor values:
// Serial.print(analogRead(zpin));

if (analogRead(zpin) >= threshold )
//Serial.println("I'm Moving");
//Serial.println("You've stopped");
// delay before next reading:


boolean checkMotion()
zMin = analogRead(zpin);
if ( zMin + threshold <= zVal){
return moveDetected;

// Function used to calibrate the Accelerometer
void calibrateAccel(){


//initialise x,y,z variables
zVal = analogRead(zpin);
zMin = zVal;
zMax = zVal;

//calibrate the Accelerometer (should take about 0.5 seconds)
for (int i=0; i<100; i++)
// Calibrate Z Values
zVal = analogRead(zpin);
else if (zVal < zMin)

// printValues(); //Only useful when connected to computer- using serial monitor.

By the end of the week, we aimed at creating the circuit complete on breadboard.

To be Continued..

Like what you read? Give HCD MDES a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.