MonsterSocket
Newbie level 4

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?
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?