Hot answers tagged

2

As I wrote in my comment, you don't actually set the value of interval to the new value, when the encoder position changes. So the blinking interval does not change. You need to use the formula to set the new value to interval. Insert interval = 60.00 / encoder0Pos * 1000; before your Serial.print() statements. Also, you need to remove the const keyword at ...


2

The basic schematic for one LED is: simulate this circuit – Schematic created using CircuitLab Make sure that: R1 is the right resistance for the supply voltage, forward voltage, and desired current M1 has a threshold low enough that the Arduino turns it fully on. Just duplicate the circuit for each LED you want to control. The code is no different ...


1

If the device turning the LEDs on / off runs on 3.3 Volts (has ground to 3.3 Volts outputs), then you might consider directly connecting the 3.3 Volt outputs to the GPIO pins of the ESP8266. If the device turning the LEDs on / off runs on higher voltages consider either using the appropriate level shifter or the appropriate optical isolator:


1

You are using Timer/Counter 1 in Fast PWM Mode with TOP set to OCR1A: OCR1Aonly describes the number to what it counts up so, 0…391 in your case. You have to define the duty cycle with OCR1B. 50% would be 195.


Only top voted, non community-wiki answers of a minimum length are eligible