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] Reading input pins of ATMEGA16

Status
Not open for further replies.

MonsterSocket

Newbie level 4
Joined
May 5, 2015
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
33
Ok, so hello everyone

I seem to have a problem with this project of mine.

Simple description

I'm using reed switches tied to ground, and to PORTD of my ATMEGA16

The magnet triggers more then one reed at time.

I need to be able to single out a reed switch as the greatest switch compared to other switches, and i can't seem to be able to do 2 things properly

I can't get the input of just one pin, otherwise this would be easy, let's start here, but a logic low means on, and I'v set PORTD = 0xFF; so pull ups are on.

How do i read and store an individual input pin and compare it to the other inputs ?

sample code :

if (PIND == (0b11111110 & 0xFF))


input = 5;



if (PIND == (0b11111101 & 0xFF))

input = 20;


If either pin is switched on, they do work, but when both are on my LEDS dont work...
DDRD = 0x00;
PORTD = 0xFF;

Whats a good way to store each pin and then compare which one is greater and my input var to the correct one?
 

Please post your circuit. You can use Proteus to draw the circuit.
 

Ok will post it soon

- - - Updated - - -

Circuit.png

Heres a basic circuit layout, Reed switches for inputs, LEDS for output

I have it where if one switch is connected i get the proper output, but if one or more switches are tied to it, nothing

- - - Updated - - -

If figured the code out its all done heres a snippet

if (~(PIND) & 0b00000001)
input=14;

if (~(PIND) & 0b00000010)
input=15;


And thats all folks
 

And it works on top down programming structure so it automatically determines highest value switch that is set
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top