Key Switch Button Module

  • Key Switch Button Module
Below you can see the corresponding code:
An example project for the KY-004
//Hello world! This time i made a very simple example on how to use a button.
//the KY-004 button module is very easy to use and requires just a small code.

int Buzzer = 3 ;
int Button = 10; 
boolean val ;

// here i set up the tones, you can change them @ void loop.
int tones[] = {261, 277, 293, 311, 329, 349, 369, 392, 415, 440, 466, 493, 523 ,554};
//              1    2    3    4    5    6    7    8    9    10   11   12   13   14
// You can add more tones but i added 14. Just fill in what tone you would like to use, 
//@ void loop you see " tone(Buzzer, tones[12]); " below,  digitalWrite(Buzzer, HIGH);
// here you can change the tones by filling in a number between 1 and 14

void setup ()
{
  pinMode (Buzzer, OUTPUT); 
  pinMode (Button, INPUT);
    //Part of buzzer tones
  for (int i = 0; i < Buzzer; i++)  ;   
}
void loop ()
{
  val = digitalRead (Button); 
    if (val == 0)  
  {
    digitalWrite (Buzzer, HIGH);
    tone(Buzzer, tones[14]);
  }
  else
  {
    digitalWrite (Buzzer, LOW);
    noTone(Buzzer);
  }
}
Specifications
Working voltage: 3.3v-5v

Write a review

Please login or register to review

Key Switch Button Module

  • Webwinkel Keurmerk en klantebeoordelingen

  • 14 dagen bedenktijd 
  • Verzendkosten voor eigen rekening
  • Product Code: KY-004
  • Availability: 14
  • 2.49€

  • Ex Tax: 2.06€

Similar Products

2 Color LED Module RG Small

2 Color LED Module RG Small

Below the corresponding code:// Arduino test code for KY011 int redpin = 11; // select the pin for ..

2.29€ Ex Tax: 1.89€

2 Color led module RG

2 Color led module RG

Below the corresponding code:// Arduino test code for KY011 int redpin = 11; // select the pin for ..

2.29€ Ex Tax: 1.89€

SMD 3 Color RGB Module

SMD 3 Color RGB Module

Below the corresponding code:int redpin = 11; // select the pin for the red LED int bluepin = 10; /..

2.36€ Ex Tax: 1.95€

Reed Switch Module

Reed Switch Module

Below the corresponding code:int Led = 13 ;/ / define LED Interface int buttonpin = 3; / / define t..

2.36€ Ex Tax: 1.95€