How do I use 1 button to randomly trigger 1 of 2 ouputs (triggering video clips)

Hi I am new to Arduino and cant seem to find an answer to my question.

I need to build a platform that when stood on randomly triggers one of two video clips. The platform will have a pressure sensor that will trigger one of two outputs from the Arduino, the outputs of the Arduino will connect to 2 inputs on a solid state video player. each of the inputs on the player triggers a different clip.

Put simply one button on the Arduino needs to trigger one of two outputs randomly.

Any help would be much appreciated

Thank you

You didn't mention what your experience level is and what you've already tried.

Part of the key about creating projects like these is breaking it down into smaller steps, and dealing with the smaller step individually. While you have at least started the process of breaking it down and thought about how to do some of the pieces, of using a pressure sensor, etc. you need to break it down further. The questions below might be snarky, it is more to try and get you to see how to break down projects into several sub-steps, rather than sitting back and hoping somebody will write the whole code for you, and give it to you free of charge.

One step would be read from a pressure sensor and if it is true, turn on the on board LED connected to digital output 13 on the Uno. Have you programmed the Arduino to do this and run it with the real sensor? Note, for the final project since you will be having people stand on the plate, have you figured out a sensor that is sensitive enough for a kid to trigger it, but will continue to work if several overweight people step on the platform?

Another step would seem to be building the platform, or at least putting the sensor under a rug and taping the wires which has nothing to do with an Arduino, but it is still crucial to the project.

Also, have you physically built the platform to hold the video screen and speaker so that people standing on the switch can see and hear the video? Have you adjusted the angle of view of the monitor and adjusted the sound so it can be heard, but doesn't blast the people?

Next up would seem to be triggering the video. Have you hooked up an Arduino so that when a switch is pressed, it starts a single video? By starting the video, I mean actually starting the video to make sure you can start the video from the Arduino.

Have you dealt with timing issues, so once the video is triggered, you don't read from the button until after the video is finished?

Have you kept track of the button state in a global/static variable so that even after the timeout, you don't start the video again until the person gets off the mat, and the next person steps on?

Have you set it up to have two buttons, and when you press the first button, it triggers the first video, and when you trigger the second button it triggers the second video? This is to make sure that you can start either video depending on the programming of the Arduino. And here, I mean actually having the second video unit attached? Rather than two buttons, you could use a global/static state variable, and the first button press do the first video, and the second button press do the second video.

Finally, we get to what on the surface seems to be your question of how to trigger a video at random, but is actually the simple part. In things like this, using your favorite search engine can often times give you the answer before asking the question on a general forum.

Does your project need to run on batteries or can you use a wall socket? Assuming a wall socket, do you have appropriate length of electrical cord for the Arduino and video? Are the cords out of sight, or have you taped them down so that people won't trip over them? If it is batteries, have you figured out how much current draw there is and what batteries to use?

Is the project going to be self contained without somebody near by? Do you have to worry about physical security to prevent people from stealing your Arduino and/or the video setup?

Thanks for that, much appreciated.

My experience level in Arduino is very basic unfortunately if that. I work for a Multimedia instruction company and am posed with task of having visitors at a heritage center stand on a fake rock that will trigger one of two videos randomly. eg in front of the Rock (platform) there is a projection of a ancient mythological king, he will tell you weather you are the rightful successor to his thrown or not. Some people are and some aren't. I have experience in projections and screens so this wont be a problem. The mechanism to fit the sensor or button in is something I will try and test but for now even just a push button would be fine.

We use a solid video player, unfortunately these players do not have the ability to play clips randomly when triggered (which would be the solution to my problem). The box that I have at the moment only has one input that can be triggered by external touch button or motion sensor etc. But from the same company I can get a player that has multiple inputs and can trigger different clips with each input. The player can be programmed using a text file so even if the Arduino is triggered multiple times the video will be uninterrupted until the current video has stopped playing.

I guess to start with you are correct in saying I should see if I can even get one output to trigger the clip. the player inputs only require a closed circuit or a short to trigger the clips. I will try this to start with and then move to the next step you suggest of using 2 buttons and see where that takes me.

I would prefer to have a standalone player that randomly played clips when triggered. If you can think of an easier solution to my problem that would void the use of Arduino that would be great.

Thanks for your help and ill re post how I got on, you might help me if/when I run into more issues

Arduinos aren't really powerful enough to display video on their own, so you would need something to do the actual video part.

However, if you move up to something like a Raspberry Pi, you could do the whole thing in one system. The R-pi has both composite and HDMI video output, so you could use whatever display technology you want, including using a car backup monitor and speaker, that you could put into a single box. The R-pi isn't as good as the Arduino for real time data control, but for waiting until one button is pressed, it would do. However, programming it is somewhat different than the Arduino, since you are using the Linux operating system. If a 4.3" car backup monitor is ok, I would suspect you could do the whole thing for under $100.

There are other similar systems, such as Beagle Bone Black ( or PCduino ( that hook up to HDMI monitors.

Alternatively, you could use an Android system, either reusing a cell phone, or something like:

Sticking with the Arduino, if you are interfacing with an existing unit, you could do the selection electronically, or you could even have the Arduino press a button with a servo (you could have two servos to press two different buttons). It is better to do it electrically, but it depends on what you are trying to interface with, and whether you can hack/mod the video unit to interface with the Arduino.

I wouldn't use the random() function, the values it returns are not very random at all and it will produce the same sequence of values every time. When the button is pressed, I'd look at the number of milliseconds since the program started, and activate one output of the other depending on whether that number is odd or even.

I wouldn’t use the random() function, the values it returns are not very random at all and it will produce the same sequence of values every time. When the button is pressed, I’d look at the number of milliseconds since the program started, and activate one output of the other depending on whether that number is odd or even.

Well, you need to seed the random number with something random (the random page suggests using an analog input that is not grounded) to get different values, but just using millis () after the button was pressed and check the bottom bit as you suggest would work also. If you use micros (), it might be the bottom bit doesn’t vary as much.