preview

Assignment 1: Bootlodeer By Nicholas Kiser

Better Essays
/* * Hw4.c * * Created: 11/17/2015 * Author: Nicholas Kiser */ #ifndef F_CPU #ifdef USING_BOOTLOADER #define F_CPU 2000000UL #else #define F_CPU 8000000UL #endif #endif #include #include #include #include #include "U0_LCD_Driver.h" #include "ADC.h" static int follow = 0; // For determining Full or Local select static int fullSweepActive = 0; // For determining full sweep static int localSweepActive = 0; // For determining local sweep static int primary = 15; // The primary angle static int degrees = 0; // Current degree value void SetupInterrupts(); void BootLoaderFixes(); void FullSweep(); void LocalSweep(); int main() { // Initialize LCD with starting values LCD_Init(); LCD_WriteDigit('F',3); LCD_WriteDigit('T',4);…show more content…
Get the second ADC value if ((primary - 10) > 0){ OCR0A = primary - 10; } else{ OCR0A = 0; } _delay_ms(500); read2 = ADCAquire(); // Primary + 10 degrees. Get the third ADC value if ((primary + 10) < 90){ OCR0A = primary + 10; } else{ OCR0A = 90; } _delay_ms(500); read3 = ADCAquire(); // If follow is 0, Follow the light if (follow == 0){ // If read1 the lowest (brightest) if ((read1 < read2) && (read1 < read3)){ primary = primary; } // If read2 the lowest (brightest) if ((read2 < read1) && (read2 < read3)){ primary = primary - 3; degrees -= 10; if (degrees < 0){ degrees = 0; } } // If read3 the lowest (brightest) if ((read3 < read1) && (read3 < read2)){ primary = primary + 3; degrees += 10; if (degrees > 180){ degrees = 180; } } } // Else, Avoid the Light else { // If read1 the greatest (dimmest) if ((read1 > read2) && (read1 > read3)){ primary = primary; } // If read2 the greatest (dimmest) if ((read2 > read1) && (read2 > read3)){ primary = primary -
Get Access