Skip to content

Instantly share code, notes, and snippets.

@eroeber
Created February 21, 2019 06:03
Show Gist options
  • Save eroeber/2f3a3f4f90917da6852dc7c25917d851 to your computer and use it in GitHub Desktop.
Save eroeber/2f3a3f4f90917da6852dc7c25917d851 to your computer and use it in GitHub Desktop.
int button1 = 2;
int button2 = 3;
int button3 = 4;
int button4 = 5;
int button5 = 6;
int button6 = 7;
int b1state = 0; // to read button1
int b2state = 0; // to read button2
int b3state = 0; // to read button2
int b4state = 0; // to read button2
int b5state = 0; // to read button2
int b6state = 0; // to read button2
void setup() {
// set button pins as input
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
pinMode(button4, INPUT);
pinMode(button5, INPUT);
pinMode(button6, INPUT);
//initialize serial communications
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
b1state = digitalRead(button1);
b2state = digitalRead(button2);
b3state = digitalRead(button3);
b4state = digitalRead(button4);
b5state = digitalRead(button5);
b6state = digitalRead(button6);
// check button functionality &
// write all the variables serially to p5.js (format matters)
Serial.print(b1state);
Serial.print(",");
Serial.print(b2state);
Serial.print(",");
Serial.print(b3state);
Serial.print(",");
Serial.print(b4state);
Serial.print(",");
Serial.print(b5state);
Serial.print(",");
Serial.println(b6state);
// delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment