Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] reading a pin

2004-02-20 by Cobb, Quentin

Well in codevisionC it's really easy...

// Input  Port E, Pin 1
#define TESTPIN1  	PINE.1
// Output Port E Pin 2
#define TESTPIN2  	PORTE.2

DDRE = 0b111110;  // All pins outputs except 1
PORTE= 0b000001;  // Enable ouptuts, pullup input pin 1



 while (!stop)
     { 
            TESTPIN2 = TESTPIN1; //light led IF Pin 1 is high (assuming high
lights LED)
     }




-----Original Message-----
From: inpactmicro [mailto:brendan.oflynn@nmrc.ie] 
Sent: February 19, 2004 9:29 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] reading a pin


   basic stuff I know but Im banging my head against a wall

Im trying to READ a pin (see if Its set high or low by a switch and 
turning on another testpin - LED on the basis of that
the (supposedly) input pin is on PinE1 (on testpin2)
the output pin iis on PINEo (Testpin 1)

this is my definitions
#define TESTPIN2  	(PINE, 0x01)
#define TESTPIN1_HI  sbi(PORTE, 0x00)
#define TESTPIN2_HI  sbi(PORTE, 0x01)
#define TESTPIN2_IN cbi(DDRE, 0x01)
#define TESTPIN1_LO  cbi(PORTE, 0x00)
#define TESTPIN2_LO  cbi(PORTE, 0x01)

 //init_devices();

 while (!stop)
      { 
                TESTPIN1_HI; //light led
		TESTPIN2_IN;//set direction of input pin (DDRE)
		
		if ((TESTPIN2 == 0) //if switch is off
		   TESTPIN1_LO;

     }
but nothing happens after the led comes on the first time
regardless of the polarity put on the TESTPIN2

can anyone help?

thanks
Bren




 
Yahoo! Groups Links

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.