dimming and turning on and off a led

i am new to the arduino but i have aldready worked with the raspberry pi.
i want help with:

1: how to controll an led with gui from the arduino with switches that can dim as well as switch the led on and off

THANKING YOU
chirag gupta

Hi chirag,

I think ou are asking two questions: (1) how to create a GUI with switches, and (2) how to control an LED.

  1. GUI = graphical user interface. Do you have a graphical app with virtual switches, or are you using real switches? The answer to the first question depends on which you mean.

  2. LED intensity is controlled with a technique called pulse width modulation (PWM), which is implemented on an Arduino using the analogWrite function. On a Uno, there are six pins that support PWM: 3, 5, 6, 9, 10, and 11. The function allows you to adjust the intensity of the LED in 1/2 % steps (approximately), from 0 (0%) to 255 (100%).

The following code is an example of how to set an LED connected (in series with a resistor) to my Arduino Uno's GPIO digital pin 3. It is set to full intensity (100% on). You can change the 255 to a different number to see how it changes.

void setup() {
  // put your setup code here, to run once:

  // this sets up pin 3 to be an output
  pinMode(3, OUTPUT);

  // set the brightness of the attached LED from 0-100%
  analogWrite(3, 255);  // change this value to change the brightness of the LED 0=off, 255=100% on.
}

void loop() {
  // do nothing.
}

Pat.

i want to use graphical switches not the real ones
amd i want to make a gui in which there are 2 switches and one slide switch
1:on
2:off
3:slide from 0 to 255

Hi Chirag,

I'm not very skilled in iOS or Android development, so I can't really tell you how to write a phone app to connect with your Arduino. I assume you want to control it with a phone. Or are you looking to control the LED with a touchscreen attached to your Arduino?

There are Bluetooth / phone options you may be interested in. See LINK. Is this what you're looking for?

Depending on your answer, there are different folks here that can help.

Pat.

look i want to be very clear and specific:
I want a code from which i can controll the brightness of an led and the blink rate of the led
the led that i am using is a 1 watt led
i want to interface with it by GUI
there should be 3 buttons
1:on and off
2:blink rate slide switch
3:brightness slide switch

and please help me with the pins i should use

chirag_0012:
look i want to be very clear and specific:

You have already got clear and specific advice. How much time have you spent thinking about it?

You may find this Python GUI demo useful.

If you want someone to write a program for you then ask in the Gigs and Collaborations section and be prepared to pay.

...R