Problems on analog pins 26 and 27

Hello, I guess it will be a quick question...

I am using RGB Led pfrom pjrc on pins 25,26 and 27. When I digitalWrite(pin, HIGH) on the three of them it comes white which is normal but if I do analogWrite(pin, 255) on each it comes red...

Looks like analogRead() is working but not sure.

Any idea, has it something to do with the MOSI1 stuff ?

Thanks for the help.

C++:
#include <Arduino.h>


// led
const byte ledRPin_ = 25;
const byte ledGPin_ = 26;
const byte ledBPin_ = 27;

void setup()
{
  pinMode(ledRPin_, OUTPUT);
  pinMode(ledGPin_, OUTPUT);
  pinMode(ledBPin_, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  //setLedColor(255,255,255);
  //analogWrite(ledRPin_, 255);
  //analogWrite(ledGPin_, 255);
  //analogWrite(ledBPin_, 255);
  digitalWrite(ledRPin_, HIGH);
  digitalWrite(ledGPin_, HIGH);
  digitalWrite(ledBPin_, HIGH);
 
}


void loop()
{
}
 
I use the 4.1 board (sorry I didnt mentionned it). 26 and 27 are described as A12 and A13. I thought it was the way to indicate it could do analog stuff. Am I missing something ?
 
26 and 27 are described as A12 and A13. I thought it was the way to indicate it could do analog stuff.

This means they can be used with analogRead().

To be usable with analogWrite(), the pin must have "PWM". You should also know analogWrite() isn't truly analog. It creates a stream of fast pulses which has an analog-like effect for things like LEDs where the light is actually blinking is much faster than the human eye can see.
 
Hello,

Thanks for the quick answer. Sorry I misunderstood and thought analogRead() and analogWrite() would use same functionnality. After looking at the T4.0 board description, I understood which functions were linked to functionnalities.

Have a good day.
 
Back
Top