Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] problem regarding ADC

Status
Not open for further replies.

Mohammad Nasim

Newbie level 1
Newbie level 1
Joined
Jul 21, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
12
hello everyone!
I faced a problem with this simple code where I wanted to flash IR transmitters, get the ADC values and show them on the LCD.
But the compiler gives some errors , which I can not understand ..


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * sensor_with_adc_2.c
 *
 * Created: 7/20/2013 8:20:42 PM
 *  Author: Nasim
 */ 
 
 
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include "adc.h"
#include "lcd.h"
 
 
#define LCD_PIN PORTB;
#define SENSOR_PIN PORTD;
 
 
void lcd(void);
void lcd_show(uint16_t );
 
int main(void)
{
    uint8_t i;
    uint16_t adc_value;
    
    DDRB = 0xFF;
    DDRC = 0xFF;
    DDRD = 0xFF;
    
    adc_init();
    lcd();
    _delay_ms(15);
    
    while(1)
    {
        SENSOR_PIN = 0x00;
        
        for(i=0;i<5;i++)
        {
            SENSOR_PIN = (1<<i);
            _delay_ms(10);
            SENSOR_PIN = 0x00;
            
            PORTC = (PORTC & 0x00) | (1<<i);
            adc_value = adc_read(PORTC);
            
            lcd_show(adc_value);
        }
        
    }
}
 
void lcd(void)
{
    lcd_init(LCD_DISP_ON );
    lcd_clrscr();
    lcd_home();
    lcd_gotoxy(0,0);
}
 
void lcd_show(uint16_t n)
{
    char adc[4];
    itoa(n,adc,4);
    lcd_puts(adc);
    _delay_ms(1000);
}

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top