#include <inavr.h>
#include <ioavr.h>
Include dependency graph for LED_sensor.c:
Go to the source code of this file.
Functions | |
void | Calibrate_Sensor (void) |
void | Init_ADC (void) |
void | Init_Ports (void) |
void | Init_PWM (void) |
void | main (void) |
Variables | |
unsigned char | lightLevel |
unsigned char | maxLightLevel |
unsigned char | minLightLevel |
|
Definition at line 37 of file LED_sensor.c. References lightLevel. Referenced by main(). 00039 { 00040 unsigned char scale; 00041 unsigned char lastLightLevel; 00042 00043 scale = 0; 00044 OCR0A = 0x00; 00045 00046 00047 while(!(OCR0A == 0xFF)) 00048 { 00049 ADCSRA |= (1<<ADSC); 00050 while (ADCSRA & (1 << ADSC)) 00051 { 00052 } 00053 lightLevel = ADCH; 00054 00055 if (lightLevel > initialLightLevel) 00056 { 00057 scale ++; 00058 __no_operation(); 00059 } 00060 OCR0A ++; 00061 __delay_cycles(5000); 00062 } 00063 }
|
|
Definition at line 15 of file LED_sensor.c. References minLightLevel. Referenced by main(). 00016 { 00017 // AREF as voltage reference, sample on ADC channel 0 00018 ADMUX = (0 << REFS1) | (0 << REFS0) | (1 << ADLAR) | 0x0; 00019 // Enable ADC, and start conversion, no prescaling 00020 ADCSRA = (1 << ADEN) | (1 << ADSC) | (1 << ADIF) | 00021 (0 << ADPS2) | (0 << ADPS1) | (0 << ADPS0); 00022 00023 while (ADCSRA & (1 << ADSC)) 00024 { 00025 } 00026 00027 minLightLevel = ADCH; 00028 }
|
|
Definition at line 8 of file LED_sensor.c. Referenced by main().
|
|
Definition at line 30 of file LED_sensor.c. Referenced by main(). 00031 { 00032 00033 TCCR0A = (1<<WGM01)|(1<<WGM00)|(1<<COM0A1)|(1<<COM0A0)| 00034 (0<<CS02)|(1<<CS01)|(1<<CS00); 00035 }
|
|
Definition at line 66 of file LED_sensor.c. References Calibrate_Sensor(), Init_ADC(), Init_Ports(), and Init_PWM(). 00068 { 00069 00070 Init_Ports(); 00071 Init_ADC(); 00072 Init_PWM(); 00073 Calibrate_Sensor(); 00074 00075 for(;;) 00076 { 00077 } 00078 00079 }
Here is the call graph for this function: ![]() |
|
Definition at line 6 of file LED_sensor.c. Referenced by Calibrate_Sensor(). |
|
Definition at line 5 of file LED_sensor.c. |
|
Definition at line 4 of file LED_sensor.c. Referenced by Init_ADC(). |