No TV Unless You Exercise!





Introduction: No TV Unless You Exercise!

When I was a kid, I went to a science museum where there was a TV powered by a stationary bike that was hooked up to a generator. I’ve always thought it would be great if every TV worked that way- it would improve your health and use green energy.

This past winter I was looking for a way to stay in shape and I found an inexpensive bike stand that let me pedal my bike indoors. It worked fine but it was pretty boring, and I have trouble exercising when I'm not motivated. I remembered the TV powered by a bike and thought, "Yeah! THAT would make me want to keep going."

Well it turns out generators are pretty expensive, and turning your TV on and off repeatedly probably isn't good for it. So I made something that does the other part of the job- it makes the TV go dark unless you keep pedaling.

Update: added video of it in action

Step 1: Overview

The system has three components- a detector, an Arduino Nano, and a relay. The relay is hooked up inline to an RCA cable going from a video source to the TV. The Arduino looks for input from the detector, and if it doesn’t receive a signal within a certain amount of time (I’m using 10 seconds), it turns off the relay which opens the circuit and the input to the TV goes dark. I have a warning buzzer that goes off when there’s 2 seconds left in the countdown.

The detector I’m using is a black/white detector normally used for robot line following. I put a strip of black and white tape on the back wheel of my bicycle, which is attached to the bike stand. The Arduino is looking for BOTH black and white detections from the wheel (it is set to look for both so that you can't just position the wheel in a certain way to keep the video on). If it doesn't see both in 10 seconds, it activates a relay that turns off the video to the TV. Note- it doesn’t turn off the DVD player or the TV, it just disconnects the input until the pedaling starts again.

Once I had the code figured out, the only really tricky part was aligning the detector in the right place. You want it to be close to the wheel but not touching. I originally tried using a Hall magnetic detector, but I couldn't get it close enough to detect without it connecting occasionally.

Step 2: The Equipment

The bike stand is this one from Amazon: Amazon link

The sensor is a black/white detector, roughly $4.00 from ebay: ebay link

The Arduino is a Nano, but you could probably use any type: ebay link

The relay is a 5V relay, like this one: ebay link.

The input is a standard RCA cable like this one: Amazon link

The wires are standard F-F breadboard wires like this: ebay link

I don't remember where I got the LED or the buzzer, but they're basic stuff, and they're optional. I also used a mini breadboard but just about any would do

Step 3: Wiring

The logic flow for this is: bike -> sensor -> Arduino -> relay -> TV input

The Arduino wiring shown is as follows:

Red: 5V power to relay

Brown: GND to relay

Orange: D3 control wire to relay


Blue: 3.3V power to detector

Green: GND to detector

Yellow: D12 input from detector


Detection LED: D11 to ground (optional)

Buzzer: D4 to ground (optional, would work with an LED too)

Step 4: RCA Cable Setup

Cut a standard RCA cable in half, and strip the ends. Inside the outer insulation will be an insulated inner wire and an un-insulated outer wire. Twist the outer wires together. Strip the inner wires, and put them in to the NO and COM terminals of the relay. Hook the RCA ends of the cables up in line between the video source and the TV. Now the video won't be able to go to the TV unless the relay is closed.

Step 5: The Code

Here's the logic behind the code: there are 2 "counter" variables- one for white detection and one for black. At the beginning, they're set to "countmax", which here is 10 seconds. Every 10 milliseconds, the Arduino looks for either a high or low detection, and it sets the counter for what it finds back to countmax while the other counter drops by 10. If either counter drops below "countwarn" (2 seconds), the buzzer sounds. If either counter drops below zero, it turns off the relay so the signal on the RCA cable is opened and nothing goes to the TV.

You can edit the variables to set the max and warning times. There are lots of Instructables here about uploading an .ino file to the Arduino. I'm using a Nano, but the Uno or any other should probably work. There must be better ways to write the code, but I'm a civil engineer not a computer programmer.

If I've done it right, bikerelay.ino is attached and that's the code you need (could somebody put it on github?). Here's the ugly text version if that didn't work:

int ledpin = 13; //activates arduino light when there's a detection
int ledpin2 = 11; //activates external LED or buzzer when there's a detection int outputpin = 3; //pin the relay control is attached to int sensorpin = 12; //pin the detector is attached to int warnpin = 4; //pin used to activate warning LED or buzzer int counter = 0; //countdown since last detection int counter2 = 0; //countdown since last non-detection

//change the next 2 settings to adjust the timer intervals int countmax = 10000; //maximum level of countdown timer. 1000 = 1 second int countwarn = 2000; //when to turn on warning pin. 1000 = 1 second void setup() { pinMode(ledpin, OUTPUT); pinMode(ledpin2, OUTPUT); pinMode(outputpin, OUTPUT); pinMode(warnpin, OUTPUT); pinMode(sensorpin, INPUT); counter = countmax; counter2 = countmax; //any line with "serial" is for debugging and should be commented out if not needed because it will slow the clock down //Serial.begin(9600); //Serial.print("count: "); //Serial.println(counter); //Serial.print("count2: "); //Serial.println(counter2); } void loop() { if ( digitalRead(sensorpin) ) //what to do when there is a non-detection { digitalWrite(ledpin,LOW ); digitalWrite(ledpin2,LOW ); counter = counter - 10; counter2 = countmax; } else //what to do when there is a detection { digitalWrite(ledpin,HIGH); digitalWrite(ledpin2,HIGH); counter = countmax; counter2 = counter2 - 10; }

//serial output lines for debugging //Serial.print("count: "); //Serial.println(counter); //Serial.print("count2: "); //Serial.println(counter2); //Serial.println("-----------"); //sound a warning if either counter is above 0 but under the "countwarn" level if ( counter > 0 && counter < countwarn || counter2 >0 && counter2 < countwarn) { digitalWrite( warnpin,HIGH ); } else { digitalWrite( warnpin,LOW ); }

//turn off the output if either counter drops below 0 //these settings are for an "active low" relay. Switch "HIGH" and LOW for an active high output if ( counter < 0 ) { digitalWrite(outputpin,HIGH ); counter = 0; } else if ( counter2 < 0) { digitalWrite(outputpin,HIGH ); counter2 = 0; } else { digitalWrite( outputpin,LOW ); }

delay(10); // wait time (miliseconds) before going again


Step 6: The Results

When you start pedaling, the relay will close and the video will go to the TV. If you stop pedaling for 8 seconds, the alarm will sound. Two more seconds, and the relay will open and no more TV for you. Back to pedaling!!

It would be pretty easy to add this to a treadmill too- just put a strip of white electrical tape on the tread and point the black/white detector at it. If you wanted to get really fancy you could hook it up to a weight set too.

If you build this and like it, it would be nice if you would make a small donation to your local Humane Society.

Thanks for reading!

Coded Creations

Third Prize in the
Coded Creations



  • Game Life Contest

    Game Life Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Water Contest

    Water Contest

44 Discussions


I know this is an old post, but could you email or ring me on or 07525 757414 - it’s a uk number.

Thinks our idea is great!

Thank you

Hey plays in traffic! Great Idea. I am actually working on a variation of this myself.

I just need some clarification on the RCA cable step.

I am currently trying to hook up my Raspberry Pi to this. I am using a 3.5 mm (4 pole) plug to RCA cable to connect it to the TV instead of an HDMI. If I strip this wire and insert into the relay, how will the relay be connected to the TV?

And what does it mean to have the "relay hooked up inline to an RCA cable going from a video source to the TV"? Thanks

2 replies

Instead of the wire going straight from your Pi to the TV, it would go through the relay, which would open and close the connection. If the arduino doesn't see the detection, it will tell the relay to open, which will make the video going into your TV go dark

Hope this helps!

This is awesome! I just had a quick question. Would this work the same if you were to use an hdmi connection? If so what would you need to add?

2 replies

Look for an HDMI breakout board, like this:

If you get two of them, you can connect all of the pins, except send one set through the relay, so it can be opened and closed. You'd have to experiment to see which pin to open.

Let us know how it goes!

My High School English teacher did a similar thing to this -ible back in 1992. His kids had to pedal the bike in order to watch tv and it helped them appreciate books more. Thanks for the -ible!

Here is my commercial embodiment covered under my patent 6,179,746.


Here is my commercial embodiment covered under my patent 6,179,746.

Take a look at and see this in my patented product.

There are much easier ways to do this. Take a look at my US patent 6,179,746 that this is copying. Imitation is the sincerest form of flatrery as they say.

4 replies

would a 556 be able to sink the current needed to drive a relay like that? You would have to be pedaling quite fast to keep the design in the patent from cutting out :P

Ah Ive never seen one of those before. I guess you wouldn't need much throughput for the video signal. That is a cool idea, small coil on a reed switch greatly reduced current to close that.

As a matter of fact, if you are talking about video signals, you might also be able to just use a fet like 2N7000.

This seems like a great alternative to manually powering the TV with a generator. Well done!

I came up with another way of doing this without the arduino. Use a stepper motor or somesort of small electric generator such as a magnet and copper coil and implement the circuit in the picture. The motor will spin when the tire spins, as it spins it'll send a small voltage to the base of the pnp transistor which will keep the transistor off, once the wheel stops spinning it'll allow the base to go to ground which will allow the necessary voltage to flow through the collector and emitter right to the coil on the relay which will turn the relay off. Just sharing. :) still, great project!


Relay like this project! See what I did there... I was thinking about maybe doing it but without the arduino.