As the topic.
I used the code below. All I need is a signal that goes from 0 to 5v steadily( the first half of a triangle signal)
But the signal only growth from 40mV to 116mV then straightly jumped to 1.04V
and then from 1.14v straight to 3.2v then it increases towards 5v.
i don't understand how could things go wrong with just a single function.
please help.
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
}
void loop() {
// set the brightness of pin 9:
analogWrite(9, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
brightness = 0;
}
// wait for 30 milliseconds to see the dimming effect
delay(100);
}