Turning on/off leds very fast. Will it do harm?
That's what the analogWrite function is already doing: turning the LED on and off rapidly is called pulse-width modulation (PWM), and it's the standard way of dimming LEDs. It's perfectly safe at any reasonable frequency.