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.

Please Help, 4 button in 1 pin ADC.

Status
Not open for further replies.

didiks

Newbie level 1
Joined
May 7, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
Please Help me.
how to use this schematic for apllied in ATmega16, i use CodeVisionAVR. Please Explain step by step to config ADC. Thanks before..
**broken link removed**

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
const int ERROR = 15; // may also be 15 or 50
 
if (i > 1024 - ERROR)
return Keys.None;
 
if (i < 0 + ERROR)
return Keys.Right;
 
if (i < 180 + ERROR && i > 180 - ERROR)
return Keys.Up;
 
if (i < 390 + ERROR && i > 390 - ERROR)
return Keys.Down;
 
if (i < 580 + ERROR && i > 80 - ERROR)
return Keys.Left;
 
if (i < 780 + ERROR && i > 780 - ERROR)
return Keys.Select;
 
return Keys.None;
}

 



To detect which key is pressed, the code checks the ADC result (i) in which interval it is, based on the last column (Binary out, see fig.). But the latter depends on Vcc, the upper limit (sometimes the lower limit as well) of the ADC range. When the 3rd column can be calculated then your subroutine above can be adjusted rather easily, I mean find the values in it.
 
Last edited:
  • Like
Reactions: didiks

    didiks

    Points: 2
    Helpful Answer Positive Rating
Codevision has a wizard so open a new project , go to the ADC tab and set the ADC parameters.
Select AVCC as voltage reference, the clock should be below 200k, use free running mode and if you want to get an interrupt where the conversion ends then enable the interrupt checkbox.

Alex
 
  • Like
Reactions: didiks

    didiks

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top