Arduino LED Push button , potentiometer

Hello,

I have on Arduino Due , one potentiometer, less, wires and resistors and I want to turn on or turn of the led by using the potentiometer. This is my code:

#define LED_PIN 11
#define POTENTIOMETER_PIN A0
void setup()
{
  pinMode(LED_PIN, OUTPUT);
}
void loop()
{
  int potentiometerValue = analogRead(POTENTIOMETER_PIN);
  
  int brightness = potentiometerValue / 4;
  analogWrite(LED_PIN, brightness);
 
}

But I want also to use serial plotter or serial monitor in order to see the value of potentiometer but I can't. I think that this will be done by command Serial.println but I have managed to do it.

Can anybody else help pe ??

I want also to do this by a push button and a led

You need a Serial.begin in setup, and a Serial.println in loop, just like in the examples.

This is not an installation or troubleshooting issue.

Please remember to use code tags when posting code.

he used them but in the wrong way :slight_smile:
(I took the liberty to fix it)

Hello sotis
Take a view here to find a nice sketch as kick off:

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

1 Like

thank you very much for your prompt response. And sorry for my fault.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.