Would it be possible to convert this to assembly, I am not familiar with C at all very much.
I am attempting an 255 value exponential curve in 16 steps
I am attempting an 255 value exponential curve in 16 steps
C:
const int outputPin = 9;
void setup() {
// Set the pin as a digital output
pinMode(outputPin, OUTPUT);
}
void loop() {
// Fade the brightness from 0 (min) to 255 (max) with 40ms delay per step
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(outputPin, brightness);
delay(40);
}
}
//Setup the output PWM pin
const int outputPin = 9;
// The number of Steps between the output being on and off
const int pwmIntervals = 100;
// The R value in the graph equation
float R;
void setup() {
// set the pin connected to the LED as an output
pinMode(outputPin, OUTPUT);
// Calculate the R variable (only needs to be done once at setup)
R = (pwmIntervals * log10(2))/(log10(255));
}
void loop() {
int brightness = 0;
for (int interval = 0; interval <= pwmIntervals; interval++) {
// Calculate the required PWM value for this interval step
brightness = pow (2, (interval / R)) - 1;
// Set the LED output to the calculated brightness
analogWrite(outputPin, brightness);
delay(40);
}