Synergia AVR 0.1

ground_sensor/main.cpp

Go to the documentation of this file.
00001 /*
00002 
00003  QRD1114 Ground Sensord Example
00004  
00005  Copyright 2010 Tymon Tobolski
00006  Politechnika Wroclawska
00007  
00008 */
00009 
00010 #include <avr/io.h>
00011 #include <avr/interrupt.h>
00012 #include <util/delay.h>
00013 // #include "../../lib/lcd/lcd.h"
00014 
00015 
00016 // LCD lcd;
00017 volatile int adc_value = 0;
00018 
00019 SIGNAL (SIG_ADC){
00020         adc_value = (ADCL | (ADCH << 8));
00021         ADCSRA |= _BV(ADSC);
00022 }
00023 
00024 int main(void){
00025         // ADC init
00026         ADCSRA = _BV(ADEN) | _BV(ADIE) | _BV(ADSC) | _BV(ADPS0) | _BV(ADPS1) | _BV(ADPS2); //INIT ADC
00027         ADMUX = _BV(REFS0);
00028         
00029         sei();
00030         
00031         DDRD = 0xFF;
00032         
00033         //lcd << "adc: ";
00034         
00035     for(;;){
00036                 PORTD = ~(1 << ((adc_value+1)/128)-1);
00037                 
00038                 //lcd.gotoxy(5, 0);
00039                 //lcd << adc_value;
00040                 //lcd << "     ";
00041                 _delay_ms(50);
00042         }
00043     return 0;
00044 }
 All Classes Files Functions Variables Defines