Kann sein dass ich jetzt von euch gesteinigt werde, ich blick da aber nicht mehr durch.
Wenn ich brightness 255 sende, sollte ich doch beim auslesen auch den Wert 255 wieder auslesen müssen, richtig?
/*
Mega analogWrite() test
This sketch fades LEDs up and down one at a time on digital pins 2 through 13.
This sketch was written for the Arduino Mega, and will not work on previous boards.
The circuit:
* LEDs attached from pins 2 through 13 to ground.
created 8 Feb 2009
by Tom Igoe
This example code is in the public domain.
*/
// These constants won't change. They're used to give names
// to the pins used:
const int lowestPin = 2;
const int highestPin = 13;
void setup() {
// set pins 2 through 13 as outputs:
pinMode(lowestPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
// iterate over the pins:
// fade the LED on thisPin from brithstest to off:
for (int brightness = 1023; brightness >= 0; brightness--) {
analogWrite(lowestPin, brightness);
Serial.print(" brightness= "); Serial.print(brightness);
Serial.print(" analogRead= ");Serial.println(analogRead(lowestPin));
}
// pause between LEDs:
delay(5000);
}
brightness= 1023 analogRead= 1023
.....
brightness= 507 analogRead= 1023
brightness= 506 analogRead= 1023
brightness= 505 analogRead= 1023
brightness= 504 analogRead= 0
brightness= 503 analogRead= 0
.....
brightness= 2 analogRead= 0
brightness= 1 analogRead= 0
brightness= 0 analogRead= 0