Yahoo Groups archive

AVR-Chat

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

Message

Changing port from input to output on the fly

2006-01-31 by Ted Smith

I want to use an ATMEGA16 to drive three sets of transistors to each
switch 6 high brigtness LEDs in parallel from 1 output (240ma per set). 
There is not enough current in the AVR to connect the LEDs directly
without additional parts.
I propose to connect the AVR output pins directly to the base of a NPN
transistor.
Initially for the lights to be off, I would program the port pin as an
output at 0 volts so the NPN transistor would not conduct. 
To make the lights go on, I would change the port to an input (with
pullup resistor enabled). This internal 10k pull up resistor would
easily sink the transistor on and light up the leds connected between
the collector and vcc+ with their 165 ohm dropping resistors.
This would need no extra base resistors.

1. Can anyone see any problem with this? 

2. Is there any limit to the number of times you can change from an
input to an output and back again?

3. What would be the best way to do this with Bascom? 

There is a veiled note about having to make something tri-state when
changing from an output to an input in the specs but I cant understand it.

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.