Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led = 8;
- int led2 = 9;
- int led3 = 10;
- String inString = ""; // string to hold input
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- Serial.println("\n\nString toInt():");
- pinMode(led,OUTPUT);
- pinMode(led2,OUTPUT);
- pinMode(led3,OUTPUT);
- }
- void loop() {
- int inChar = Serial.read();
- if (isDigit(inChar)) {
- inString += (char)inChar;
- }
- if (inChar == '\n'){
- int l;
- l = inString.toInt();
- while (l >= 10){
- digitalWrite(led,HIGH);
- delay(l);
- digitalWrite(led,LOW);
- // delay(l);
- digitalWrite(led2,HIGH);
- delay(l);
- digitalWrite(led2,LOW);
- // delay(l);
- digitalWrite(led3,HIGH);
- delay(l);
- digitalWrite(led3,LOW);
- //delay(l);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement