Hello!
Guys, please help me!
I know, maybe it is not the best place for this, but I'm in desperation!
I have a problem with data processing in Processing and vibration feedback in my prototype.
From the beginning: I made a simple device using a Arduino UNO. I added bluetooth BLUEFRUIT EZ-LINK and a simple vibration motor, like the one on the bottom.
In Processing I wrote a simple program to control one object, and with one obstacle present. For example :We have two ellipses - one of them we have to move form one place to another without touching the other (the obstacle/s). If You make a mistake, you should feel vibrations.
And everything is OK if I have just one obstacle. When I am adding more objects/obstacles, vibration feedback is completely useless. It gets jammed, the response is delayed, pulse width modulation is nonexistent in this situation ( which I wanted to measure in three versions ).
If You have ANY IDEA how I can fix this, I will be really greatful.
Thanks!
P.S. I am a beginner in programming and Arduino, so I am pretty sure that there is better way to write this program.
For instance, program with I used, with a few objects:
import processing.serial.*;
Serial myPort;
int blueX = 1287;
int blueY = 655;
float blackX, blackY;
int AX, AY;
int BX, BY;
int CX, CY;
int DX, DY;
int EX, EY;
int FX, FY;
int GX, GY;
int HX, HY;
float blueSize = 30;
float blackSize = 40;
int ASize = 50;
int BSize = 30;
int CSize = 75;
int DSize = 75;
int ESize = 120;
int FSize = 75;
int GSize = 27;
int HSize = 75;
color bluecolor;
color blueActive;
color blackcolor;
color Acolor;
color Bcolor;
color Ccolor;
color Dcolor;
color Ecolor;
color Fcolor;
color Gcolor;
color Hcolor;
color colorActiveObstacle;
boolean Overblue = false;
boolean Overblack = false;
boolean OverA = false;
boolean OverB = false;
boolean OverC = false;
boolean OverD = false;
boolean OverE = false;
boolean OverF = false;
boolean OverG = false;
boolean OverH = false;
void setup()
{
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
size(500, 500);
bluecolor = color(#0000FF);
blueActive = color(#CC00FF);
blackcolor = color(000000);
colorActiveObstacle = color(34);
Acolor = color(225);
Bcolor = color(225);
Ccolor = color(225);
Dcolor = color(225);
Ecolor = color(225);
Fcolor = color(225);
Gcolor = color(225);
Hcolor = color(225);
blackX = 20;
blackY = 20;
blueX = 450;
blueY = 450;
AX = 200;
AY = 40;
BX = 320;
BY = 60;
CX = 430;
CY = 150;
DX = 300;
DY = 80;
EX = 250;
EY = 180;
FX = 100;
FY = 100;
GX = 1240;
GY = 130;
HX = 300;
HY = 500;
}
void draw()
{
background(78);
if(mousePressed)
{
fill(blueActive);
blueX = mouseX;
blueY = mouseY;
// myPort.write('H');
} else {
fill(bluecolor);
myPort.write('L');
}
ellipse(blueX, blueY, blueSize, blueSize);
fill(blackcolor);
ellipse(blackX, blackY, blackSize, blackSize);
if(overA(AX,AY, ASize))
{
fill(Acolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
fill(Acolor);
myPort.write('L');
}
ellipse(AX, AY, ASize, ASize);
if(overB(BX,BY, BSize))
{
fill(Bcolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
myPort.write('L');
fill(Bcolor);
}
ellipse(BX, BY, BSize, BSize);
if(overC(CX,CY, CSize))
{
fill(Ccolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
myPort.write('L');
fill(Ccolor);
}
ellipse(CX, CY, CSize, CSize);
if(overD(DX,DY, DSize))
{
fill(Dcolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
myPort.write('L');
fill(Dcolor);
}
ellipse(DX, DY, DSize, DSize);
if(overE(EX,EY, ESize))
{
fill(Ecolor);
// fill(colorActiveObstacle);
myPort.write('H');
} else {
myPort.write('L');
fill(Ecolor);
}
ellipse(EX, EY, ESize, ESize);
if(overF(FX,FY, FSize))
{
fill(Fcolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
myPort.write('L');
fill(Fcolor);
}
ellipse(FX, FY, FSize, FSize);
if(overG(GX,GY, GSize))
{
fill(Gcolor);
//fill(colorActiveObstacle);
myPort.write('H');
} else {
fill(Gcolor);
myPort.write('L');
fill(Gcolor);
}
ellipse(GX, GY, GSize, GSize);
if(overH(HX,HY, HSize))
{
fill(Gcolor);
myPort.write('H');
} else {
myPort.write('L');
fill(Hcolor);
}
ellipse(HX, HY, HSize, HSize);
}
boolean overA(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 60) {
return true;
} else {
return false;
}
}
boolean overB(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 50) {
return true;
} else {
return false;
}
}
boolean overC(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 73) {
return true;
} else {
return false;
}
}
boolean overD(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 73) {
return true;
} else {
return false;
}
}
boolean overE(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 95) {
return true;
} else {
return false;
}
}
boolean overF(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 73) {
return true;
} else {
return false;
}
}
boolean overG(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 50) {
return true;
} else {
return false;
}
}
boolean overH(int x, int y, int diameter) {
float disX = x - mouseX;
float disY = y - mouseY;
if (sqrt(sq(disX) + sq(disY)) < 73) {
return true;
} else {
return false;
}
}