We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to set the distance from the ultrasonic sensor. For instance, I want to play a video between 0 and 100 cm. Also I stop this video 100 between 250. But I did not write this code part. Can you help me pls ?? :( (I wrote arduino code but I stuck in processing part )
Answers
Break this down into two problems
1) Reading data from Arduino
2) Loading, starting and stopping video.
Start with task (1) there are loads of examples showing data being read from Aurduino. Once you can read your sensor data and you understand the code necessary to do that you can move onto task 2.
BTW your specification is incomplete because you don't say what you want to happen when the distance from the sensor is greater than 250cm ;)
I did these 2 steps. I read data from Arduino.
This is my processing code. I still have a problem on set value (also I don't have much knowledge about processing)
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
You can also check previous relevant posts: https://forum.processing.org/two/search?Search=ultrasonic
Kf
I modified your code so it does not depend on your serial code. Instructions: You press either 0, 1 or 2 to change state. The first state is for idle, the second state plays the second movie and the third state plays the second movie. Please watch when you access your arrays. The first array position is at zero (0) and not 1 as shown in the example below. Also, you can use this example with your serial device. For that, you will read the serial and assign it to your val. you will need to call updateVal() ONLY If the new value changes to a different state in order to play another movie.
Kf