Elektro F. schrieb:
> int ValuePoti = analogRead(Poti);
> int Output = map(ValuePoti,1,255,1,1023);
> analogWrite(Q,Output);
Sly_marbo schrieb:
> Müsste es nicht sogar so aussehen:
>
> //map(value, fromLow, fromHigh, toLow, toHigh)
>
> int Output = map(ValuePoti,1,1023,1,255);
>
> Der AD Wandler hat doch 10bit und die PWM 8?
Oder man spart sich das in diesem Fall und macht nen right shift.
1 | int ValuePoti = analogRead(Poti);
|
2 | int Output = (ValuePoti >> 2);
|
3 | analogWrite(Q,Output);
|
Dabei fällt mir grad auf, die Funktion analogWrite:
Sie erlaubt "int":
1 | void analogWrite(uint8_t pin, int val)
|
...aber in der Funktion wird nur auf == 0 oder == 255 abgefragt,
sonst kommt "val" direkt ins OCR Register.
Kann man so machen, ist halt kacke... :-D