/* * Lab 6 - Servo Control student program template * * This program will how to use the keyboard connected to a PC * running HyperTerminal can communicate with the ATmega16 on the STK500 * to manipulate the position of a servo. * * Last modified 2010-10-04 20:50 (ebw) */ #include /* * These are function prototypes for the functions that are defined below. * They are needed because C doesn't allow you to call functions before * they are declared or defined. Otherwise it doesn't know what the * parameter and return value types are for called functions when they're * used. * * Add your own code to servo_left(), servo_right(), and * servo_center() in the function definitions at the end of the file. */ void servo_left(); // Turns the servo all the way to the left. void servo_center(); // Turns the servo to its center position. void servo_right(); // Turns the servo all the way to the right. /* * This initialization function sets-up Timer0 for: * - phase Correct PWM * - clearing OC0 on up-count * - prescaled by 256 * and remembering to enable the output pin (PB3) driven by the timer. * * It also configures the bottom two pins on PORTC for LED output. */ void init() { TCCR0 = _BV(WGM00) | _BV(COM01) | _BV(CS02); DDRB = _BV(PB3); DDRC = _BV(0) | _BV(1); } int main() { init(); while (1) { /* FIXME: INSERT YOUR OWN CODE HERE USE TEST STATEMENTS TO TEST WHICH SWITCH BUTTON WAS PRESSED UTILIZE YOUR servo_left(), servo_right(), servo_center() FUNCTIONS */ } return 0; } /* * Student-provided helper functions for driving the servo. * * FIXME: Add your code to the servo_xxx() functions below. * You shouldn't have to make any changes to init(). */ void servo_left() { } void servo_center() { } void servo_right() { }