Hello. Simple schematic:
32u4 micro RobotDyn
3 potentiometers 10k connected to A5;A4;A3
1 LED RGB connected via 220R to 9 (PWM, redPin) ; 6 (PWM, greenPin) ; 4 (NOT PWM, my mistake, bluePin).
Problem? PWM works only on 9 pin. From 0V to 5V slowly rising up. On 6 pin which is PWM is only.. 0VDC or 5VDC when I turn max potentiometer. (0-1 , like normal digital Output).
As 4 pin isnt PWM - situation is clear, it will be only 0-1. Or maybe can I make something to get PWM from notPWM pin like 4??
//RGB//
int redPin = 9;
int greenPin = 6;
int bluePin = 4;
//RGB//
int potPin_red = A5;
int potPin_green = A4;
int potPin_blue = A3;
//RGB//
int readValue_red;
int readValue_green;
int readValue_blue;
//RGB//
int writeValue_red;
int writeValue_green;
int writeValue_blue;
void loop()
{
//RGB//
analogWrite(redPin, analogRead(potPin_red) / 4);
analogWrite(greenPin, analogRead(potPin_green) / 4);
analogWrite(bluePin, analogRead(potPin_blue) / 4);
}
Ok. This code works properly on PWM pins (9;6)
But when I have added IRremote (GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols) its problem. IR conected to 5 pin.
So IR remote generates problem for 6 pin PWM.
About softwarePWM I have found this library GitHub - bhagman/SoftPWM: A Wiring (and Arduino) Library to produce PWM signals on arbitrary pins. , I need to test it. But will it works when I have IRremote library with timer 4 on 6pin of 32u4?
As I see in table "Hardware specifications" on irremote github I see, that on 32u4 timer4 is using. So I need to change to other timer. Right?