Code Problem. TTP223/Buzzer

Hello:

I am a total beginner with the code. I am trying to activate a buzzer with a TTP223, but I have problems trying to integrate the two devices. This is what I did:

//detector.ino

#define PINSENSOR 7
#define BUZZER 9
int sound = 250;

int F_Estado(int pin){
return digitalRead(pin);
}

void F_Comunicacion (int Estado){
if (Estado) {
Serial.print("DETECTION");
}
else{
Serial.print("NO DETECTION");
}
Serial.println();


}

void setup() {
Serial.begin(9600);
pinMode (PINSENSOR, INPUT);
pinMode (BUZZER, OUTPUT);
}


void loop(){
 if (digitalRead( 7 )== HIGH) {
 digitalWrite (9,250);
 }
 int estadoSensor = F_Estado(PINSENSOR);
F_Comunicacion (estadoSensor);


delay(1000);
}

I wonder if someone can help me understand what that I have missing. Thank you. (First Pos

Please use code tags.

Read this before posting a programming question

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

  digitalWrite (9,250);

You digitalWrite the value HIGH or LOW, not 250.

Thank you, I changed 250 for HIGH, but still no working,

V/R

Araneo

int F_Estado(int pin){
  return digitalRead(pin);
}

What does this achieve? You wrote a function to return the pin state? Why not just use digitalRead?

I am a total beginner with the code. I am trying to activate a buzzer with a TTP223, but I have problems trying to integrate the two devices.

Where in your code are you activating a buzzer?