AVR program to have 3V in some specific micocontroller's output pin

Thread Starter

wallwell

Joined Oct 28, 2017
5
Hi

I have Atmega328 microcontroller as on this schematic.
I am not very experienced with micro controllers. I would like to know how I could program those instructions in AVR programming language:
If pushbutton is pressed
-output of pin1 = 3V
-output of pin2 = 0V
Also, I would like to know which pins from the attached schematic should I use for that: analog, digital or other type?

Thank you
 

Attachments

AlbertHall

Joined Jun 4, 2014
12,625
You need some kind of editor software in which to write the program in some programming language (which you will have to learn), a compiler to make the program into something the processor can understand, software to send the program to the processor, hardware to program the processor, and a lot more knowledge of the processor than you do now.

Can I suggest that you start with an Arduino. There is a free integrated development environment (IDE) and all you need to program the Arduino is a USB cable. The IDE comes with example programs to blink LEDs, read buttons and so on.
https://www.arduino.cc/
 

be80be

Joined Jul 5, 2008
2,395
Kind of hard to get 3 volt output the pin is going to be the supply voltage. So if that's 5 volts you get five volts now you could run slower clock and the chip at 3 volts.
If you mean with pwm the output is still supply voltage it's just toggled to make it look lower.
But without a filter your not going to have a true 3 volt output.
You need a chip with DAC
 

philba

Joined Aug 17, 2017
959
Maybe you should tell us more about what you are trying to do. Are you taking a class? Is this part of a project? Or are you just curious and want to learn about microcontrollers?
 

AlbertHall

Joined Jun 4, 2014
12,625
Kind of hard to get 3 volt output the pin is going to be the supply voltage. So if that's 5 volts you get five volts now you could run slower clock and the chip at 3 volts.
If you mean with pwm the output is still supply voltage it's just toggled to make it look lower.
But without a filter your not going to have a true 3 volt output.
You need a chip with DAC
Or just a potential divider to reduce the 5V from the pin to 3V.
 

be80be

Joined Jul 5, 2008
2,395
output of pin1 = 3V
Don't think he had divider or a buffer in mind.
More like something where he gets 3 volts.
I was just pointing out a 5 volt avr atmega like his doesn't have that.
Lots of ways to get it done .
 
Top