NOTE:- I WANT TO TURN "ON" LED(PIN NO13) WHEN THE LED (PIN NO 9)(ANALOG) REACHES TO ITS MAX BRIGHTNESS(255) AND AGAIN TURN OFF THE LED(PIN13) WHEN BRIGHTNESS OF PIN 9 IS LESS THAN 255
MY PROGRAM:-
//LED Blink (half brightness)
int ledPin = 9;//the Arduino pin that is connected to the LED
int brightness = 0;
void setup() {
pinMode(ledPin, OUTPUT);// initialize the pin as an output
pinMode(13, OUTPUT);
}
void loop() {
// int brightness = 0;
analogWrite(ledPin, brightness);//brightness = 0
delay(50);// short delay
brightness += 1;
THANK YOU @aarg.
the code worked for me ,thanks a lot
i also tried this
//LED Blink (half brightness)
int ledPin = 9;//the Arduino pin that is connected to the LED
int brightness = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);// initialize the pin as an output
pinMode(13, OUTPUT);
}
void loop()
{
// int brightness = 0;
analogWrite(ledPin, brightness);//brightness = 0
delay(50);// short delay
brightness += 1;
Good for using code tags, but can you please post the whole of the program that does not do what you want as we don't know exactly what you have changed.
Because analogWrite uses PWM. I'm a bit confused, because your comment line lists PWM pins, so you seem to already know this. As you indicated, your LED is on a pin that lacks PWM.