Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int cirkel = 13; // the number of the pushbutton pin
- const int triangel = 11;
- const int rektangel = 6;
- const int kvadrat = 3;
- const int oval = 5;
- const int star = 10;
- const int hexagon = 4;
- const int heart = 5;
- const int romb = 9;
- const int piezo = 12; // the number of the LED pin
- // variables will change:
- int buttonState = 0; // variable for reading the pushbutton status
- int lastButtonState = LOW;
- void setup() {
- // initialize the LED pin as an output:
- pinMode(piezo, OUTPUT);
- // initialize the pushbutton pin as an input:
- pinMode(cirkel, INPUT);
- pinMode(kvadrat, INPUT);
- pinMode(hexagon, INPUT);
- pinMode(triangel, INPUT);
- pinMode(oval, INPUT);
- pinMode(heart, INPUT);
- pinMode(rektangel, INPUT);
- pinMode(star, INPUT);
- pinMode(romb, INPUT);
- }
- void loop() {
- // read the state of the pushbutton value:
- buttonState = digitalRead(kvadrat);
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(cirkel);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(hexagon);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(triangel);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(heart);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(rektangel);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(star);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- buttonState = digitalRead(romb);
- // check if the pushbutton is pressed.
- // if it is, the buttonState is HIGH:
- if (buttonState == HIGH) {
- // turn LED on:
- digitalWrite(piezo, HIGH);
- delayMicroseconds(1200);
- digitalWrite(piezo, LOW);
- delayMicroseconds(1200);
- } else {
- // turn LED off:
- digitalWrite(piezo, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement