aboutsummaryrefslogtreecommitdiff
path: root/esp32/lego-piano.ino
diff options
context:
space:
mode:
Diffstat (limited to 'esp32/lego-piano.ino')
-rw-r--r--esp32/lego-piano.ino18
1 files changed, 9 insertions, 9 deletions
diff --git a/esp32/lego-piano.ino b/esp32/lego-piano.ino
index 3cd5986..4a88556 100644
--- a/esp32/lego-piano.ino
+++ b/esp32/lego-piano.ino
@@ -22,7 +22,7 @@ int currentLed = 0;
int lastSeen = 100;
const int rows[] = { 5, 23, 19, 18, 26 };
-const int cols[] = { 34, 33, 35, 21, 22 };
+const int cols[] = { 7, 33, 8, 21, 22 };
const int adc[] = { 2, 4, 12, 27, 14 };
const int ampEnable = 32;
@@ -37,8 +37,8 @@ void setup() {
dac_output_enable(DAC_CHANNEL_1);
for (int i=0;i<5;++i) {
- pinMode(rows[i], OUTPUT);
- pinMode(cols[i], OUTPUT);
+ pinMode(rows[i], OUTPUT|PULLUP);
+ pinMode(cols[i], OUTPUT|PULLDOWN);
pinMode(adc[i], INPUT);
}
@@ -68,18 +68,18 @@ void mute() {
}
void tristate(int pin) {
- pinMode(pin,OUTPUT);
+ pinMode(pin,OUTPUT|PULLDOWN);
digitalWrite(pin,LOW);
pinMode(pin,INPUT);
}
void power(int pin) {
- pinMode(pin,OUTPUT);
+ pinMode(pin,OUTPUT|PULLUP);
digitalWrite(pin,HIGH);
}
void ground(int pin) {
- pinMode(pin,OUTPUT);
+ pinMode(pin,OUTPUT|PULLDOWN);
digitalWrite(pin,LOW);
}
@@ -105,7 +105,7 @@ int sense(int led) {
int value = analogRead(adc[row]);
- //Serial.println(value);
+ Serial.println(value);
return value < 500;
}
@@ -144,7 +144,7 @@ void loop() {
/* Serial.println(currentLed); */
enableLed(currentLed);
- delay(1);
+ delay(5);
if (sense(currentLed)) {
if (lastSeen != currentLed) {
lastSeen = currentLed;
@@ -158,5 +158,5 @@ void loop() {
mute();
}
- currentLed = (currentLed+1)%25;
+ currentLed = (currentLed+1)%10;
} \ No newline at end of file