1)does it lower or step up the voltage only?
when I read gpio pin, do I read voltage and when I write I set the voltage?
I can't say read or write current value?
2)can i also control power v*I to the output pin.both current and voltage.
(not by adding resistor just by software)
3)why certain pins are considered PWM. can't I just just flip
the voltage by software, to any digital pin?
thankx
1: When you select a GPIO as INPUT or OUTPUT your telling the software how to act. The microcontroller then knows what to do.
A digital OUTPUT has a value of "0" or "1", it corresponds to OFF and ON.
2: No. It's 0V for OFF and 5V for an ON value. You can PWM an output but it's not the same.
3: The PWM digital outputs have a high switching oscillator compared to the normal ones. It can simply switch on and off faster.
Writing to a GPIO pin means that on the physical level you either activare the upper or lower transistor of a half bridge. These transistors are either fully on or fully off. The drive ability is normally 40mA source or sink. When reading a pin you will read a "0" when the input voltage is lower than 0,2Vcc. When the input voltage is higher than 0,7Vcc you will read a"1". In between these voltages the level is undefined. The last part of your questions makes no sense since measuring a current implies connecting the measuring device in series with the load.
No, normally you apply a constant voltage to a load and the load takes a certain amount of current at that voltage dependent on the load (and inner resitance of the source). Outputs are digital wich means that you either apply full voltage or no voltage
Yes you can turn any pin on and off with a certain duty cycle. But PWM pins can do this in hardware which is much faster and saves you a lot of coding
Sure, you can do PWM in software by turning any pin on and off - but your code has to be doing that. With the PWM pins, you just set the PWM duty cycle with analogWrite() and your code doesn't have to do any work to keep the pwm running.
2)can i also control power v*I to the output pin.both current and voltage.
(not by adding resistor just by software)
There is no software control over the current output. The output transistors will turn on and source (high output) or sink (low output) as much current as the external circuit allows. If that exceeds 20mA, the high out will droop to 4.2V or lower, and the low out will wise to 0.9V or higher. See Table 29-1 and the notes below it.
If the current exceeds 40mA (Absolute Max current), the output transistor is likely to be damaged - maybe immediately, or maybe a little longer.
C-F-K:
A digital OUTPUT has a value of "0" or "1", it corresponds to OFF and ON.
Well, no, that is misleading really, it presumes a certain convention for switching which just as often works the other way around. You should explain that a value of "0" or "1" corresponds to LOW or HIGH where LOW means a connection to the ground or zero volt line and HIGH means a connection to the supply, generally 5V line.
The important thing is that there is a second register associated with I/O ports called the Data Direction Register which determines whether the output drivers are enabled ("turned on") or disabled ("off"). With the corresponding part of the DDR written as LOW (0), you can write to the primary port register but the actual port pin will not be forced to the value written though there is a function defined as "INPUT_PULLUP" which means that if the port register is written HIGH with the pin defined as an input, the port will supply a small current to act as a "pull-up". In any case, the output register will retain the value so that if the DDR is switched to an output, that output will then correspond to what was last written to the port register.
C-F-K:
You can PWM an output but it's not the same.
Well, what in fact happens is that the output is rapidly switched between LOW and HIGH according to a hardware counter which once set, continues indefinitely and entirely independent of the execution of other software. It is not an indeterminate or variable voltage; at any given instant it is either HIGH or LOW with the full (that is, must be limited to about 20 mA) current driving capability of the chip.
C-F-K:
3: The PWM digital outputs have a high switching oscillator compared to the normal ones. It can simply switch on and off faster.
Not sure what the "normal ones" might be here. PWM is effected by one of the group of timer modules in the chip, which are generally similar. There are however certain associations between particular timers and particular pins such that PWM is only available on certain pins, and even then, only a certain number of PWM allocations may be made at any one time.