You seem to confuse a triangle wave with a sawtooth.
You only need a single resistor, which you alternate between HIGH and LOW to charge and discharge. I think
you must have somehow arranged that the capacitor is charged by a 100k:100k resistor divider to
half the supply voltage.
MarkT, I think you are right, I have confused a triangle and sawtooth. I removed the second resistor and now, I am reaching 5 volts, but it is not returning to zero.
Discharging a capacitor through an output pin - I think you need to be careful here. It could be quite a lot of current (even though it's only for a tiny fraction of a second).
I don't know what the specs are for a transient current spike like that but the idea makes me feel bad.
Thank you guys, it was my silly mistake.
I figured that the reason it was not returning to 0 volts is because I had set the for loop counter increment as
i+1 and not i = i+1. That solved it!!!
Thanks again. This forum is very quick in responding and I was pleasantly surprised.
The code and output wave are down below.
GypsumFantastic:
Discharging a capacitor through an output pin - I think you need to be careful here. It could be quite a lot of current (even though it's only for a tiny fraction of a second).
I don't know what the specs are for a transient current spike like that but the idea makes me feel bad.
I am with you on this one, but it's a triangle, not a saw. to create a saw there should be a diode to drain the voltage back down, but that is a little risky a dare say.