Exemplo n.º 1
0
int problemTwo(unsigned int pins[], char a0[], char a1[], int pos, int mode){
	printf("Entering Problem two with positions %d\n", pos);
	
	int values[40];
	int average, min, minpos; 
	char t0;
	min = 10000;
	
	int i = 0;
	for(i = 0; i < 40; i++){
		average = 0;
		average = (analogRead(a0) + analogRead(a1))/ANALOG_INPUTS;
		if(average < min){
			min = average;
			minpos = i;
			//printf("minpos delta is %d \n", minpos);
		}
		values[i] = average;
		printf("the current average was found to be %d \n", average);
		pos = smallClockwiseRotation(pins, pos);
	}

	printf("The minimum position was found at %d \n", minpos);
	
	pos = problemThree(pins, pos, minpos);
	
	problemFour(pins, pos, a0, a1, mode);
	return pos;

}
Exemplo n.º 2
0
int main(int argc, char** argv) {
	// Lab two problems
	problemOne();
	problemTwo();
	problemThree();
	problemFour();
	problemFive();
	problemSix();
	problemSeven();
	problem8();
	problem9();
	problem10();

    // Pass any applicable command line arguments to GLUT. These arguments
	// are platform dependent.
    glutInit(&argc, argv);

	// Set the initial window size
	glutInitWindowSize( 400, 400 );

	// Create a window using a string and make it the current window.
	glutCreateWindow("CSE 618 Lab2");

	// Indicate to GLUT that the flow of control should return to the program after
	// the window is closed and the GLUTmain loop is exited.
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	// GLEW does not entirely support the Core GLUT Profile out of the box. 
	// The following statement fixes the problem.
	glewExperimental = GL_TRUE;

	// Intilize GLEW. This must be done after glut is initialized.
	GLenum res = glewInit();
	if (res != GLEW_OK) {
		fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
		return false; // GLEW could not be initialized.
	}

	// Callback for window redisplay
	glutDisplayFunc(RenderSceneCB);		
	glutReshapeFunc(ResizeCB);

	// Set window clear color
	glClearColor( 0.0f, 0.0f, 0.0f, 1.0f);

	// Unbind shader in use to enable fixed function pipeline functionality (compatability mode)
	glUseProgram(0);
	
	// Enter the GLUT main loop. Control will not return until the
	// window is closed.
    glutMainLoop();

	return 0;

} // end main