Hello everybody,
I am new with programming the Arduino Uno, so i am asking for a bit of assistance with my project.
I need the Arduino to work as 3 separated pwm's that are controlled by 3 pot resistor on 80 kHz with a duty cycle from between the 0 and 50%. It is meant to control 3 high power LED's separately.
What i found so far on the internet is:
#include <PWM.h>
int32_t frequency = 80000;
// Analog inputs connected to the variable resistors
const int knobPin1 = 1; // LED 1 control
const int knobPin2 = 2; // LED 2 control
const int knobPin3 = 3; // LED 3 control
// PWM outputs connected to LED driver circuits
const int drivePin1 = 9;// LED 1 drive
const int drivePin2 = 10;// LED 2 drive
const int drivePin3 = 11;// LED 3 drive
// initial value for the variable resistors
int knobValue1 = 0;
int knobValue2 = 0;
int knobValue3 = 0;
void setup() {
// set the drive pins as output:
pinMode(drivePin1, OUTPUT);
pinMode(drivePin2, OUTPUT);
pinMode(drivePin3, OUTPUT);
}
void loop() {
// read the variable resistors, convert it to 0 - 255
knobValue1 = analogRead(knobPin1) / 4;
knobValue2 = analogRead(knobPin2) / 4;
knobValue3 = analogRead(knobPin3) / 4;
// use the data to control the drive:
analogWrite(9, knobValue1);
analogWrite(10, knobValue2);
analogWrite(11, knobValue3);
}
I am sure it is incomplete because i just used what i had found and combined it.
Can somebody please tell me how to make this working as described above, and also explain what is doing what so i can learn how to program this my self in the future for other purposes.