Help to edit coding after I change the hardware part from tutorial

Im using these component for my project and the code im using:

-Arduino UNO R3 16U2 with USB
-400 tie point interlocking solderless breadboard
-Arduino TTP223 Capacitive Touch Sensor Module ; IoT
-M to M and M to F jumper wire

byte noteON = 144;//note on command
byte note;//storage for currently playing note

int buttonPin = 7;
int potPin = A0;
boolean currentState = LOW;//stroage for current button state
boolean lastState = LOW;//storage for last button state

void setup(){
  pinMode(buttonPin, INPUT);//this time we will set the pin as INPUT
  Serial.begin(9600);//initialize Serial connection
}

void loop(){
  currentState = digitalRead(buttonPin);
  
  if (currentState == HIGH && lastState == LOW){//if button has just been pressed
    
    int currentPotVal = analogRead(potPin);
    note = map(currentPotVal, 0, 1023, 0, 127);
  
    MIDImessage(noteON, note, 127);//turn note on with 127 velocity
    delay(2);//crude form of button debouncing
  } else if(currentState == LOW && lastState == HIGH){
    MIDImessage(noteON, note, 0);//turn note off
    delay(2);//crude form of button debouncing
  }
  lastState = currentState;
}

//send MIDI message
void MIDImessage(byte command, byte data1, byte data2) {
  Serial.write(command);
  Serial.write(data1);
  Serial.write(data2);
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

If you post your code we can help?
Post links to your hardware please?
What model Arduino are you using?

Thanks.. Tom.... :slight_smile:

A pot delivers a stead signal, that changes only when the pot is adjusted differently. A piezo instead reacts on changes only (touch or sound), and delivers zero with no change. Of course these different signal types must be handled differently as well. You should understand that difference, and how both signals can be used to affect the rest of your program.