Difference between revisions of "Arduino 5 - jas LED"

From DT^2
Jump to: navigation, search
(Created page with "<syntaxhighlight lang="C++"> int jas; void setup() { pinMode(11, OUTPUT); Serial.begin(9600); jas = 255; } void loop() { if (Serial.available()) { char c = Ser...")
 
m
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
 
       if (jas < 255) jas++;
 
       if (jas < 255) jas++;
 
     if (c == '-')
 
     if (c == '-')
       if (jas > 0) jas--;
+
       if (jas > 0) jas--;  
  }
+
    analogWrite(11, jas);   
  analogWrite(11, jas);   
+
    Serial.println(jas);
 
   }
 
   }
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 11:38, 29 July 2019

int jas;

void setup() {
  pinMode(11, OUTPUT);
  Serial.begin(9600);
  jas = 255;
}

void loop() {
  if (Serial.available())
  {
    char c = Serial.read();
    if (c == '+') 
       if (jas < 255) jas++;
    if (c == '-')
       if (jas > 0) jas--; 
    analogWrite(11, jas);   
    Serial.println(jas);
  }
}