Hello everyone,
im working on a rgb led to display different colours at random just to get familiar with the program.
now i would like to read the output from port 9 (red), 10(green) and 11(blue)
however i only read either the port number which is not what i want
or
i read the formula for "waarde" which works but if its not a led it would not tell me if the signal really goes trough the output
so i decided to use the read function, but i think its not working (see below in serialprint) because its an input function being asigned to an output, so what do i do here?
So how do i read the actual PWM value sent trough the port ?
appreciate the advice
Here is the code,
int ledPinRood=9;
int ledPinGroen=10;
int ledPinBlauw=11;
unsigned char waarde;
unsigned char waardeRood;
unsigned char waardeGroen;
unsigned char waardeBlauw;
void setup()
{
pinMode(ledPinRood,OUTPUT);
pinMode(ledPinBlauw,OUTPUT);
pinMode(ledPinGroen,OUTPUT);
Serial.begin(9600);
}
void loop()
{
waardeRood=analogRead(ledPinRood);
waardeGroen=analogRead(ledPinGroen);
waardeBlauw=analogRead(ledPinBlauw);
waarde=(random(0,255));
analogWrite(ledPinRood, waarde);
analogWrite(ledPinBlauw, waarde);
analogWrite(ledPinGroen, waarde);
Serial.print("rood ,");
Serial.print(waardeRood);
Serial.print(", ");
Serial.print("groen ,");
Serial.print(waardeGroen);
Serial.print(", ");
Serial.print("blauw ,");
Serial.print(waardeBlauw);
Serial.print(", ");
Serial.println(waarde);
delay(2500);
and the serial print that comes with it ;
16:09:59.530 -> rood ,255, groen ,212, blauw ,223, 87
16:10:02.047 -> rood ,17, groen ,230, blauw ,238, 40
16:10:04.572 -> rood ,13, groen ,228, blauw ,235, 232
16:10:07.065 -> rood ,29, groen ,251, blauw ,4, 122
16:10:09.538 -> rood ,212, groen ,200, blauw ,179, 39
16:10:12.033 -> rood ,66, groen ,54, blauw ,14, 47
16:10:14.551 -> rood ,60, groen ,36, blauw ,251, 60