Pages: [1]   Go Down
Author Topic: Arduino to respond to Android phone vibrations (via Amarino)  (Read 674 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I'm new to Arduino (and Amarino) and I'm looking for some help with a school project. People here seem a little more active than the forum on Amarino, so I figure I try my luck here  smiley-red

I'm using:
- Lilypad Simple (it's the new one, and after much frustration, it came down to jumping the power from + to VCC...)
- Bluetooth Mate Silver
- Lilypad Vibe Board
- Samsung Galaxy S3

I want the Lilypad vibe board to vibrate according to different notifications I get from my Android phone. For instance, a text message is 2 short pulses and a phone call is a series of continuous pulses. Does anyone know where I can find a tutorial on this or already have a code I can build off of? I only got as far as being able to pair my phone with the Lilypad + BT modem and run the MeetAndroid>Test Event.

Ideally I want it to also respond to social notifications as well (Facebook, Twitter etc.). In this case, the ideal final solution is for the Lilypad vibe board to react exactly the same as the vibration motor inside my phone (since the phone already have different vibration patterns to different notification events). Is there code for this? Or any suggestions?

Any help is much appreciated! Thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Having next to none programming knowledge, I managed to get this far from picking various bits in the library/tutorials.

The problem with something like this is that the text message HAS to be 'hey'....which is pretty useless. What needs to change in the code so that ANY text message notification will set off the vibration motor on the Arduino side?


Code:
#include <MeetAndroid.h>
// declare MeetAndroid so that you can call functions with it
MeetAndroid meetAndroid;
// starting with 1 LED
int vibe = 10;
void setup()
{
  // use the baud rate your bluetooth module is configured to
  // not all baud rates are working well, i.e. ATMEGA168 works best with 57600
  Serial.begin(115200);
  // register callback functions, which will be called when an associated event occurs.
  meetAndroid.registerFunction(LEDon, 'A');  
  pinMode(vibe, OUTPUT);
  digitalWrite(vibe, LOW);
}
void loop()
{
  meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void LEDon (byte flag, byte numOfValues)

{

  int values[]={
    0  };

  meetAndroid.getIntValues(values);

  //Text message content
  int X=values[1];
  if (X = 'hey') {
    digitalWrite(vibe, HIGH); // set the Vibe on
    delay(800);              // wait for a second
    digitalWrite(vibe, LOW);    // set the Vibe off
    delay(800);
    digitalWrite(vibe, HIGH);
    delay(800);
    digitalWrite(vibe, LOW);  
     }

  else
  {
    digitalWrite(vibe, LOW);
  }
}
« Last Edit: November 30, 2012, 12:59:04 am by sealichen » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 600
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  int values[]={
    0  };
The size of the array is defined either in the square brackets or counting initializers. Pray, tell what advantage a one element array has over a scalar variable.

Code:
  int X=values[1];
  if (X = 'hey') {
A one element array does not have an element at index 1. The value X can be assigned the multibyte character 'hey' but what good is that?

Quote
The problem with something like this is that the text message HAS to be 'hey'
If you expect to store "hey" in one character, you are going to be disappointed. Why you want to store characters in an int escapes me. How you think you are going to store 4 characters, including the trailing NULL, in a two byte int escapes me.

Quote
What needs to change in the code so that ANY text message notification will set off the vibration motor on the Arduino side?
Lots of stuff. To start with, getIntValues() is not the way to retrieve a test message.
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 83
Posts: 3362
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At one point, I too had the meetAndroid sketch, but it was not working for me and because I already know Java, I went ahead and made my own Android program to talk to my robot. Since your new to programing (all programing in general), Java may be a little TOO much for you.

HOWEVER, If by some chance you do learn some java, you might want to start with a program called Bluetooth Chat. It is a basic program that can scan for bluetooth devices and establish a connection to talk to one another. I used that very program to first test my robot to see if the BT module worked or not, and fom there on I made my own.

I also successfully just recently made a Arduino controller with a 3.2" touchscreen, accelerometer and BT master module, that is byfar MUCH cheaper to buy and program than the Samsung Galaxy S2 tablet I used.


** I will see if I can get the meetAndroid sketch again and try to point you in the right direction.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: [1]   Go Up
Jump to: