Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int Row[2] = { 2, 1 }; // initialize the row and column pins
- const int Col[3] = { 3, 4, 0 };
- int c1 = 1; // set up vars for the column states
- int c2 = 1;
- int c3 = 1;
- void setup() {
- // set modes of rows and columns
- pinMode(Row[0], OUTPUT);
- pinMode(Row[1], OUTPUT);
- pinMode(Col[0], INPUT);
- pinMode(Col[1], INPUT);
- pinMode(Col[2], INPUT);
- digitalWrite(Col[0], HIGH); //enable the internal pull up resistors
- digitalWrite(Col[1], HIGH);
- digitalWrite(Col[2], HIGH);
- }
- void loop() {
- digitalWrite(Row[0], LOW); //pull low the row we are querying
- digitalWrite(Row[1], HIGH);
- c1 = digitalRead(Col[0]); //grab button states
- c2 = digitalRead(Col[1]);
- c3 = digitalRead(Col[2]);
- if (c1 == LOW) {
- Remote.decrease();
- Remote.clear(); //reset the key state to prevent repeating keys
- c1 = 1;
- delay(200); //debounce
- }
- else if (c2 == LOW) {
- Remote.mute();
- Remote.clear();
- c2 = 1;
- delay(200);
- }
- else if (c3 == LOW) {
- Remote.increase();
- Remote.clear();
- c3 = 1;
- delay(200);
- }
- digitalWrite(Row[0], HIGH); //select the other row
- digitalWrite(Row[1], LOW);
- c1 = digitalRead(Col[0]);
- c2 = digitalRead(Col[1]);
- c3 = digitalRead(Col[2]);
- if (c1 == LOW) {
- Remote.previous();
- Remote.clear();
- c1 = 1;
- delay(200);
- }
- else if (c2 == LOW) {
- Remote.TogglePlay();
- Remote.clear();
- c2 = 1;
- delay(200);
- }
- else if (c3 == LOW) {
- Remote.next();
- Remote.clear();
- c3 = 1;
- delay(200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement