How to read from Grounded switch

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to read from Grounded switch

469 Views
jonathan_abbati
Contributor III

Hello Friends!

 

I am working on the EVALH1 board which has some switches integrated onto Port T which I would like to utilize, but they are all hooked to ground without a power sourer running to them.  I have tried playing with the playing with the data direction of the ports and supply them with power, but I am left with a very dim light due to my looping. Here is the code I am using, I have a feeling that I am simply overlooking something very small within the various of this following code:

 

void main(void) {

 

DDRH = 0xFF; // LEDs

DDRT = 0xFF; // Switches
PTT = 0xFF;

 

while(1)

{

 

DDRT = 0xFF;

PTT = 0xFF;

DDRT = 0x00;

   
    if (PTIT_PTIT6 == 1)
        PTH_PTH1 = 1;
   
    if (PTIT_PTIT6 == 0)
        PTH_PTH1=0;

}

 

The main question I have would be: how do I read from these switches if they are connected to ground?

 

Thank you so much for your time and I greatly appreciate anything you may be able to share with me!

 

Sincerely,

Jonathan
 

Labels (1)
0 Kudos
1 Reply

389 Views
mculater
Contributor III

Enable the internal pullup resistors for PORTT via the PERT register.

 

Best regards,

Carl Barnes

www.technologicalarts.com

AMPS:  Adapt Modular Prototyping System for Microcontrollers

Since 1995

EVALUATE * EDUCATE * EMBED

0 Kudos