Arduino who help me

Hello, I should ask something about arduino then I have a variable that goes from zero to 100 and I would like when it arrives at a certain imposed value a certain value raises a Pin. Who explane me

Hi @r0x15, This has a variable that ramps up to 100 repeatedly, switches the led on if greater than 50. Not sure if you want the led set on/off each time, or only as it goes through 50. Anyway this should get you started. (It compiles, but not tested as don’t have an Arduino with me today.)

int led = 13;
int count;

void setup() {
  pinMode(led, OUTPUT);

void loop() {
  if (count > 50) {
    digitalWrite(led, HIGH);
  } else {
    digitalWrite(led, LOW);
  count = count % 100;

Hi RicharDL
Thank you for your reply
No, I just have to set let’s say a scale from 0 to 100, if I set 20 from 0 to 20 the led is on above 20 up to 100 it stays off

Ciao RicharDL
Grazie per la risposta
No devo solo impostare ammettiamo una scala da 0 a 100, se imposto 20 da 0 a 20 il led è acceso sopra 20 fino a 100 rimane spento

Hi @r0x15, I’m not clear what the problem is. You want the led action reversed? You could swap ‘High’ and ‘Low’, or you could change ‘> 50’ to ‘<50’. You can adjust the numbers to suit.

You can look at the examples, in Processing, File, Examples, Basics, Controls, Conditionals. (Not the most exciting examples, but good use of conditionals.) Similarly in the Arduino IDE, File Examples, Basics, Digital there is Button, DigitalInputPullup, and StateChangeDetection. With all those examples of logic you should have the tools to do whatever you want.

1 Like