Skip to content

Instantly share code, notes, and snippets.

@carlosdelfino
Created March 6, 2014 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosdelfino/9400973 to your computer and use it in GitHub Desktop.
Save carlosdelfino/9400973 to your computer and use it in GitHub Desktop.
Alterna For, conforme botão prescionado.
onst int buttonPin1 = 2;
const int buttonPin2 = 3;
int valor=0;
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
Serial.begin(9600);
}
void loop() {
botoes();
// escolha();
}
void botoes(){
for(int i=0;( digitalRead(buttonPin1) && !digitalRead(buttonPin2)) && (i<100);i++){
valor=i;
Serial.print("valor1 ");
Serial.println(valor);
}
for(int i=0;( !digitalRead(buttonPin1) && digitalRead(buttonPin2)) && i<100;i++){
valor=i;
Serial.print("valor2 ");
Serial.println(valor);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment