Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Flag not registered on: January 09, 2013, 10:23:59 am
i remove the function in pin 8. it was supposed to be attach to switch.. the send button i was talking about is the GUI in android
2  Using Arduino / Programming Questions / Re: Flag not registered on: January 09, 2013, 09:45:26 am
i did but it will not send so i tried putting it in my show function
 and it just keeps sending 1 without pressing the send button. can you help
Code:
#include <MeetAndroid.h>

MeetAndroid meetAndroid;

int ledPin = 13;

void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  pinMode (8, INPUT);
 
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
 
  meetAndroid.registerFunction(show, 'A');
   
}

void show(byte flag, byte numOfValues) {
  delay(500);
 
 
  meetAndroid.send ("1");
}

void loop() {
  meetAndroid.receive();
}
3  Using Arduino / Programming Questions / Re: Flag not registered on: January 09, 2013, 08:05:20 am
can you scarp that. it was supposed to be connected to a switch.

now the code looks like this.
Code:
void loop() {
  meetAndroid.receive();
 // if (digitalRead (8) == 1) {
 //   digitalWrite (ledPin, HIGH);
 //  delay (2000);
//    digitalWrite (ledPin, LOW);
    meetAndroid.send ("1");
 // }
}


now it can send 1 but it just keeps sending 1. without pressing the send button...
can you teach me what should i do? because of the deadline cant think straight right now.
4  Using Arduino / Programming Questions / Flag not registered on: January 09, 2013, 05:51:48 am
Hi! all, first of all i want to apologize to my previous post and im new to this arduino stuff. So excuse me for, i may not be able to explain my problem clearly. im using arduino mega 2560, BlueSMiRF Gold, Galaxy mini (2.3.4), installed amarino 1.0 and the amarino plugin bundle.

the code below is to send an integer from arduino to the phone using Bluetooth by linking the program to use the amarino library. But when i press the send button it receives `Flag not registered`. I want to send integer 1 whenever the send button is pressed.
Please good sir, im at my wits end.

can anyone check my code and point me where in the code is wrong and what i should do to make it work.

Over here is the code for the android phone
Code:

package com.android.bluetoothtry;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import at.abraxas.amarino.Amarino;
import at.abraxas.amarino.AmarinoIntent;

public class MainActivity extends Activity implements OnClickListener {

private static final String DEVICE_ADDRESS = "00:06:66:08:16:AD";
private static final char ARDUINO_FLAG = 'a';

private Button _buttonConnect;
private Button _buttonSend;
private Button _buttonDisconnect;

private BroadcastReceiver _arduinoReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int type = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1);

if(type == AmarinoIntent.STRING_EXTRA) {
String value = intent.getStringExtra(AmarinoIntent.EXTRA_DATA);
Toast.makeText(MainActivity.this, value, Toast.LENGTH_SHORT).show();
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

registerReceiver(_arduinoReceiver, new IntentFilter(AmarinoIntent.ACTION_RECEIVED));

/*
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS);

Toast.makeText(MainActivity.this, "Device Connected " + address, Toast.LENGTH_SHORT).show();
}
}, new IntentFilter(AmarinoIntent.ACTION_CONNECTED));
*/

_buttonConnect = (Button) findViewById(R.id.buttonConnect);
_buttonSend = (Button) findViewById(R.id.buttonSend);
_buttonDisconnect = (Button) findViewById(R.id.buttonDisconnect);

_buttonConnect.setOnClickListener(this);
_buttonSend.setOnClickListener(this);
_buttonDisconnect.setOnClickListener(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.buttonConnect:
connect();
break;
case R.id.buttonSend:
send();
break;
case R.id.buttonDisconnect:
disconnect();
break;
default:
break;
}
}

private void disconnect() {
Amarino.disconnect(this, DEVICE_ADDRESS);
}

private void send() {
int data = 1;
Amarino.sendDataToArduino(this, DEVICE_ADDRESS, ARDUINO_FLAG, data);
}

private void connect() {
Amarino.connect(this, DEVICE_ADDRESS);
}
}



And over here is the code for arduino
Code:
#include <MeetAndroid.h>

MeetAndroid meetAndroid;

int ledPin = 13;

void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  pinMode (8, INPUT);
 
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
 
  meetAndroid.registerFunction(show, 'A');
}

void show(byte flag, byte numOfValues) {
  delay(500);
}

void loop() {
  meetAndroid.receive();
  if (digitalRead (8) == 1) {
    digitalWrite (ledPin, HIGH);
    delay (2000);
    digitalWrite (ledPin, LOW);
    meetAndroid.send ("1");
  }
}

 

Please help good sir..
5  Community / Gigs and Collaborations / Build Ball Maze controlled via gingerbread phone on: December 13, 2012, 05:50:25 am
Hi, all first of all i want to apologize if don't know much about arduino. just starting to learn and if my English might not better explain what i'm trying to say. i found this project here ( http://www.instructables.com/id/DIY-Android-Ball-Maze-An-Introduction-to-the-And/ ) and im planning to improve it by adding a 3 stage board connected in a stair case style, the highest board would be the easy stage next the medium then the hard board. Plus  a automatic ball picker  using a conveyor that would carry the ball back to the board. with timer that will server as a score for the user.
The project name is 3 stage ball maze controlled via gingerbread android phone, using arduino mega 2560

Features:

1. it got a 3 stage, easy, medium and hard levels

2. controlled by an android phone gingerbread 2.3.4 or 2.3.6 version

3. it got an conveyor that would carry the ball back to the same board it has fallen into. after 3 tries it will go back to the first board which is the easy board.

now i understand that the materials needed for the project would be the following.

amarino 2.0
Arduino Mega 2560
standard servo motors x 6pcs
Bluesmirf Mate Gold to connect it to the phone 3pcs. one each per board
a 4 pin or 2 pin unipolar or bipolar stepper motor for the ball picker.
and a IR sensor that will detect anything that passes through it that will serve as a switch if anything that passes have count to 3 then will reverse to counterclockwise.

i need help in its programming side, coz im just a beginner that want to build something cool. i understand that as a beginner this is way to much for me. but i really want this to be realize before Christmas. i have already build the case, but don't have the right program to go with it.


Good Sir im asking if anyone of you could help me.

Feel free to edit or change the code.


i have here the code for the single board.

Code:

#include <Servo.h>
#include <MeetAndroid.h>

float data[3] = {0};
int intdata[3] = {0};
int i = 1;
Servo myservo;
int pos = 0;

MeetAndroid meetAndroid(error);

void error(uint8_t flag, uint8_t values){
  Serial.print("ERROR: ");
  Serial.print(flag);
}

  void setup() {
  Serial.begin(115200);
 meetAndroid.registerFunction(floatValues, 'A');  
  myservo.attach(9);
}

void loop()
{
  meetAndroid.receive();}

void floatValues(byte flag, byte numOfValues)
{
  meetAndroid.getFloatValues(data);
  for (int i=0; i<3;i++)
  {
    meetAndroid.send(data[i]);
  }

  if (-10<=data[1]<=10)   {
     intdata[1] = int(data[1]);
     intdata[1] = intdata[1]+10;
     pos = intdata[1]*9;
     myservo.write(pos);
  }
     if (-10<=data[0]<=10)   {
     intdata[0] = int(data[0]);
     intdata[0] = intdata[0]+10;
     pos = intdata[0]*9;
     myservo.write(pos);
  }

}


 
Pages: [1]