Author Topic: drive gnd with attiny... possible?  (Read 2852 times)

0 Members and 1 Guest are viewing this topic.

Offline HalfordTopic starter

  • Contributor
  • Posts: 29
drive gnd with attiny... possible?
« on: March 25, 2015, 10:20:10 am »
Hello everyone,

I'm a real beginner and I'm building an adapter for a video receiver.
to select the channel you have to short gnd output (see picture).



I do that with a dip switch, but for the project I have I would like to do it with a simple button.

Can I drive that with an ATTiny?I mean replace the dip with the ATTiny85?

Thanks

Hal.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9925
  • Country: nz
Re: drive gnd with attiny... possible?
« Reply #1 on: March 25, 2015, 10:43:43 am »
yes, you can drive those channel pins with an ATTiny and make your own pushbutton controls in code.

One issue you need to be aware of is voltage. I suspect those dip switch inputs are 3.3V.
If you feed 5V into them from a ATTiny you will probably damage it.

What you can do is change the ATTiny outputs between output mode (with logic low) and input mode (floating).
This will be the same as what the DIP switch does.

In one state the pin will pull to ground and in the other state it will be floating. No 5V is ever produced so there is no damage to the chip.
However this is risky because you could make a mistake while coding and accidentally set the output to high.
So i recommend you put some resistors between the attiny and the IC. 1K in each connection should be fine.

For your coding
DDRx sets input vs output
PORTx changes function depending on if DDRx is set for input or output
If it's an output PORTx sets if the output is GND or 5V (0=low and 1=high)
If it's an input PORTx enables/disables the internal pullup

So you want to set the bits in PORTx to 0  (so its always GND when set as an output)
Then you can write code to change DDRx bits between 0 or 1  (0=switch off  1=switch off)
« Last Edit: March 25, 2015, 10:58:10 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline HalfordTopic starter

  • Contributor
  • Posts: 29
Re: drive gnd with attiny... possible?
« Reply #2 on: March 25, 2015, 10:50:18 am »
great news ! thank you!

I saw that the operating voltage for an ATTiny85 is from 2.7v to 5.5v.... couldn't I run the whole board with 3.3v so no issues will happen?

Thanks again for the help

Hal.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: drive gnd with attiny... possible?
« Reply #3 on: March 25, 2015, 10:54:04 am »
I saw that the operating voltage for an ATTiny85 is from 2.7v to 5.5v.... couldn't I run the whole board with 3.3v so no issues will happen?

Excellent idea  :-+
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9925
  • Country: nz
Re: drive gnd with attiny... possible?
« Reply #4 on: March 25, 2015, 10:54:30 am »
Yes, if you run the attiny from 3.3V you never have to worry about it.

You could forget about switching i/o between input and output state and just drive them as outputs.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline HalfordTopic starter

  • Contributor
  • Posts: 29
Re: drive gnd with attiny... possible?
« Reply #5 on: March 25, 2015, 10:58:09 am »
yess!

great news!

Thank you for the inputs, this weekend I'll try to do a sketch for the code

thanks again

Hal.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf