Exemplo n.º 1
0
int main(void)
{	DDRB=0xFF;
	DDRC=0x00;
	PORTC=0xFF;
	PORTB=0x00;
	
	while(1)
	{   
		
		if((bit_is_clear(PINC,2)) && (bit_is_set(PINC,4)) && (bit_is_set(PINC,3)) && (bit_is_clear(PINC,5)))
		straight();
		else if((bit_is_set(PINC,2)) && (bit_is_set(PINC,4)) && (bit_is_clear(PINC,3)) && (bit_is_clear(PINC,5)))
		left();
		else if((bit_is_clear(PINC,2)) && (bit_is_clear(PINC,4)) && (bit_is_set(PINC,3)) && (bit_is_set(PINC,5)))
		right();
		else if((bit_is_set(PINC,2)) && (bit_is_set(PINC,4)) && (bit_is_set(PINC,3)) && (bit_is_clear(PINC,5)))
		leftin();
		else if((bit_is_clear(PINC,2)) && (bit_is_set(PINC,4)) && (bit_is_set(PINC,3)) && (bit_is_set(PINC,5)) )
		rightin();
		else if ((bit_is_clear(PINC,2)) && (bit_is_clear(PINC,4)) && (bit_is_clear(PINC,3)) && (bit_is_clear(PINC,5)))
		discont();
		else if((bit_is_set(PINC,2)) && (bit_is_set(PINC,4)) && (bit_is_set(PINC,3)) && (bit_is_set(PINC,5)))
		stop();
	}
	
}
Exemplo n.º 2
0
main ()
{
char filename[200];
FILE *f;
float x;
int i;
int driver, mode, status;
float c, d;
float co, dis;

	out = fopen ("out.lis", "w");
	if (out == NULL)
	{
		perror ("out.lis");
		out = stdout;
	}
/*
	printf ("Fichier cours? ");
	gets (filename);
	f = fopen (filename, "r");
	if (f == NULL)
	{
		perror (filename);
		return;
	}

	for (i=0; i<MAX; i++)
	{
		if (feof(f))
			break;
		fscanf (f, "%f", &x);
		cours[i] = x;
	}

	n = i;
*/
	/* n = sizeof (cours) / sizeof (cours[0]); */

/*
	for (i=0; i<n; i++)
	{
		printf ("%04d : %4.2f\n", i, cours[i]);
	}
*/

/*
	driver = DETECT;
	mode = 0;

	initgraph (&driver, &mode, "c:\\tc");
	status = graphresult ();
	if (status != grOk)
		printf ("Erreur initgraph %d 0x%X\n", status, status);

	for (i=0; i<n; i++)
		putpixel (i+1, (8-cours[i])*100, 10);

	restorecrtmode ();
*/

/*
	for (d=0.001; d<0.1; d*=1.1)
		simul (d);

*/
	calcul_cours ();
#if 1
	for (i=0; i<sizeof(tab_cours)/sizeof(tab_cours[0]); i++)
	{
		co = cont (tab_cours+i);
		dis = discont (tab_cours+i);
		printf ("\n%s %f %f\n", tab_cours[i].nom, co, dis);
		/*for (c=1000/Euro; c<2000000/Euro; c*=2)
			simul (0.045, c, tab_cours+i);*/
		for (c=1000/Euro; c<2000000/Euro; c*=4)
		for (d=0.001; d<0.1; d*=2)
			simul (d, c, tab_cours+i);
	}
#else
/*
	i=0;
	c=2442;
	d=0.01;
	simul (d, c, tab_cours+i);
*/
	simul (0.01, 152.67, tab_cours+4);
#endif
	fflush (out);

}