Java and Arduino .. possible?

Hi , im new using this board called arduino and recently i was programing an elevator , the problem is that i dont know if is possible make a function that still working in all the program , i mean a function that can be able to recive data in any time.... I need this because when I have to call the elevador it can be in any time , so....

I was thinking programing in Java but I don't how to start , what libraries i need to use or what are commands there , i have to use the function digitalwrite/digitalread normally?

Thanks , and sorry if it's a basic question :s ....

i mean a function that can be able to recive data in any time.

Yes this is what it does.

I was thinking programing in Java

Why?
There is no point and I don't think it is possible anyway.

Forget Java and use the C/C++ Arduino is designed for.

As for your app, it sounds simple enough but we need more (and precise) information. What are the inputs, what do you expect to happen when these inputs are received etc.


Rob

Sounds like he wants a sort of pseudo-threading with an interrupt on an input of some sort.

Well , here is my function

void activarPiso(){

if(digitalRead(botonpbPin) == HIGH) {
botonpb = 1;
digitalWrite(sensorpbPin, HIGH);
}

if(digitalRead(botonunoPin) == HIGH) {
botonuno = 1;
digitalWrite(sensorunoPin, HIGH);
}

if(digitalRead(botondosPin) == HIGH) {
botondos = 1;
digitalWrite(sensordosPin, HIGH);
}

if(digitalRead(botontresPin) == HIGH){
botontres = 1;
digitalWrite(sensortresPin, HIGH);
}
}

I mean , i want that my program stay in "stand by" in order to recieve a signal (push botton) in any time (this function read my botton and turn on the sensor of the floor) , cuase in a elevator you dont know when a person it's gonna call a floor...

Looks like you've got working code, just put a call to activarPiso() in the loop() area and make sure all your botonxxx variables are global.

Alternatively put the

if(digitalRead(botonpbPin) == HIGH) {
  botonpb = 1;
  digitalWrite(sensorpbPin, HIGH);
}
  
if(digitalRead(botonunoPin) == HIGH) {
  botonuno = 1;
  digitalWrite(sensorunoPin, HIGH);
}


if(digitalRead(botondosPin) == HIGH) {
  botondos = 1;
  digitalWrite(sensordosPin, HIGH);
  }


if(digitalRead(botontresPin) == HIGH){
  botontres = 1;
  digitalWrite(sensortresPin, HIGH);
  }

inside loop()


Rob

I understand but that function is only a part of my whole code, i know that in C languaje a program is runing line per line , so if i have another instruccions after this... this function still recieving information?? Thanks

so if i have another instruccions after this... this function still recieving information??

Yes, if you have

loop() {

    do stuff
    activarPiso();
    do stuff

}

your function will be called every time the main loop iterates and will appear as though everything is happening immediately and at the same time.

But don't allow "other stuff" to take a long time. If "other stuff" will take a long time then you have to look at using interrupts.


Rob

Thanks , i'll check it ...

Connecting your Arduino with a Java program on the PC is possible - if you want I can send you the Libraries.

It is capable of operating the serial monitor, i.e. sending and receiving bits/bytes etc.

For instance check this project that I made with it: