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.

avr and dip switch... problem

Status
Not open for further replies.

sherazi

Banned
Joined
Feb 15, 2010
Messages
388
Helped
61
Reputation
126
Reaction score
61
Trophy points
1,318
Location
Muscat, Oman, Oman
Activity points
0
regards

i am using a dip switch to select mode of operation in an var based project...
both on means step mode and if its not 11 then its normal operation..



the concerned code parts are given below
Code:
DDRB = 0x3E;		//	port b is output except PB0, PB6 and PB7
PORTB =0X00;

Code:
b=PINB;
	b|=0x3F;
	if(b=0xff) //means step mode
	{
		goto step_full_open;
	}
        else goto normal_mode;


now what so ever i do i get a normal mode... i had even checked voltage at the pins of avr using DMM... plz point out whats wrong?
 

If you leave input without anything connected you can't conclude if it's in high (1) or low (0) state.
You have to use a resistor to pull it up to VCC or pull down to GND.

You can use the internal pullip resistor (PORTx to "1" for specific bit when pin is in input mode) to keep a pin connected via an internal pullup resistor (around 50k) to VCC and connect the dipswitch/resistors to GND.
This way you will have high state (1) when dipswitch is off and low state (0) when dipswitch is on.

Please look into avr documentation/io ports for more informations.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top