Skip to content

Commit 180e514

Browse files
authored
Merge pull request #2259 from jedgarpark/step-switch-arduino
first commit Arduino version of step switch pico demo
2 parents f187d08 + 1df856c commit 180e514

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Step_Switch_Pico_Demo_Arduino/.pico_rp2040.test.only

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-FileCopyrightText: 2022 John Park for Adafruit Industries
2+
// SPDX-License-Identifier: MIT
3+
// Step Switch Party for Pico
4+
5+
// extra library used:
6+
// Bounce2 -- https://github.com/thomasfredericks/Bounce2
7+
8+
#include <Wire.h>
9+
#include <Bounce2.h>
10+
11+
12+
const int num_buttons = 4;
13+
const int led_pins[num_buttons] = {2, 3, 4, 5};
14+
const int button_pins[num_buttons] = {6, 7, 8, 9};
15+
Bounce buttons[num_buttons];
16+
bool led_vals[num_buttons];
17+
18+
19+
void setup() {
20+
Serial.begin(9600);
21+
delay(1000);
22+
Serial.println("Step Switch Pico Party");
23+
24+
for (uint8_t i=0; i< num_buttons; i++){
25+
buttons[i].attach( button_pins[i], INPUT_PULLUP);
26+
}
27+
28+
for (uint8_t i=0; i< num_buttons; i++){
29+
pinMode(led_pins[i], OUTPUT);
30+
digitalWrite(led_pins[i], HIGH);
31+
led_vals[i] = HIGH;
32+
}
33+
}
34+
35+
36+
void loop() {
37+
for (uint8_t i=0; i< num_buttons; i++){
38+
buttons[i].update();
39+
if( buttons[i].fell()) {
40+
// do something here, such as send MIDI, change a NeoPixel animation, etc.
41+
Serial.println(i);
42+
led_vals[i] = !led_vals[i];
43+
digitalWrite(led_pins[i], led_vals[i]);
44+
}
45+
}
46+
47+
}

0 commit comments

Comments
 (0)