Advertisement
tomateblue

BlinkSemaforo

Jun 3rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. int led = 8;
  2. int led2 = 9;
  3. int led3 = 10;
  4.  
  5. String inString = "";    // string to hold input
  6.  
  7.  
  8. void setup() {
  9.   // put your setup code here, to run once:
  10.   Serial.begin(9600);
  11.   Serial.println("\n\nString toInt():");
  12.   pinMode(led,OUTPUT);
  13.   pinMode(led2,OUTPUT);
  14.   pinMode(led3,OUTPUT);
  15. }
  16.  
  17. void loop() {
  18. int inChar = Serial.read();
  19.   if (isDigit(inChar)) {
  20.      inString += (char)inChar;  
  21.   }
  22.   if (inChar == '\n'){
  23.     int l;
  24.     l = inString.toInt();
  25.     while (l >= 10){
  26.      digitalWrite(led,HIGH);
  27.      delay(l);
  28.      digitalWrite(led,LOW);
  29.     // delay(l);
  30.  
  31.      digitalWrite(led2,HIGH);
  32.      delay(l);
  33.      digitalWrite(led2,LOW);
  34.    //  delay(l);
  35.  
  36.      digitalWrite(led3,HIGH);
  37.      delay(l);
  38.      digitalWrite(led3,LOW);
  39.  //delay(l);  
  40.     }
  41.   }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement