Commit | Line | Data |
---|---|---|
1 | /* Software voltage regulator using analog read and PWM | |
2 | Connect both voltage sensor and output pin to possitive side of capacitor | |
3 | Then connect negative side to ground | |
4 | Voltage should be approximatelly stabilized at AREF/2 | |
5 | You can use some push-pull (totem pole) kind of buffer at output pin to supply more current | |
6 | */ | |
7 | ||
8 | ||
9 | #define SENSOR A0 | |
10 | #define OUTPIN 11 | |
11 | ||
12 | void setup() { | |
13 | } | |
14 | ||
15 | void loop() { | |
16 | analogWrite(OUTPIN, map(analogRead(SENSOR), 0, 1023, 255, 0)); | |
17 | } | |
18 | ||
19 |