<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>ej</title>
<style type="text/css">
td {
	text-align: center;
}
</style>

<script type="text/javascript" >
function high(salida) { 
	var c;//c almacena el color del led
	
	c = "#ff0000";
		
	setTimeout('document.getElementById(' + salida + ').style.background ="'+ c+ '"',tiempo);	
}
  		
 function low(salida) { 
 	setTimeout('document.getElementById(' + salida + ').style.background ="#FFFFFF"',tiempo);	
 
}

var tiempo = 0;

function pausa(milisegundos) {
	tiempo = tiempo + milisegundos;
}

var tiempoDp;//almacena el tiempo que tarda p() en ejecutarse
function p() {//aquí debemos escribir el programa que se repite una sola vez
	tiempo = 0;
		//apagamos todas las salidas
	for (i=0;i<8;i++) {
		low(i);
		
	}
		pausa(200);//un retraso inicial para ver mejor el inicio del programa
	//escribir aquí el programa
	
	high (3);
	
	pausa (2000);
	high (4);
	high (5);
	pausa (1000);
	low (4);
	
				
}

function bucle(){//esta función se comporta como un bucle infinito sobre la función p()
	p();
	setInterval('p()',tiempo);

}
function reinicio() {

document.location.href = document.location.href;

}
</script>

</head>
<body onload="p()"><!-- bucle() para bucle infinito  y p()para una sola vez.Esto carga el programa nada mas cargar la página-->



<table border="1" cellpadding="2" cellspacing="2">
	<tbody><tr>
		<td  id="7">7</td>
		<td  id="6">6</td>
		<td  id="5">5</td>
		<td  id="4">4</td>
		<td  id="3">3</td>
		<td  id="2">2</td>
		<td id="1">1</td>
		<td id="0">0</td>
		
	</tr>
	
</tbody></table>
<br>

<input value="reiniciar" onclick="reinicio()" type="submit">
</body></html>