Created
August 8, 2018 05:07
-
-
Save atifahsuad/d0cb71a4796fd779db2a289760e49d45 to your computer and use it in GitHub Desktop.
This is a sample code for Piano (Basic)'s Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This example code is for Piano(Basic)'s Tutorial. | |
Product page: | |
Maker UNO: https://www.cytron.io/p-maker-uno | |
Created by: | |
08/08/18 Suad Anwar, Cytron Technologies | |
*/ | |
#include "pitches.h" | |
#define C 3 | |
#define D 4 | |
#define E 5 | |
#define F 6 | |
#define G 7 | |
#define A 9 | |
#define B 10 | |
#define Buzzer 8 | |
void setup() | |
{ | |
pinMode(C, INPUT_PULLUP); | |
pinMode(D, INPUT_PULLUP); | |
pinMode(E, INPUT_PULLUP); | |
pinMode(F, INPUT_PULLUP); | |
pinMode(G, INPUT_PULLUP); | |
pinMode(A, INPUT_PULLUP); | |
pinMode(B, INPUT_PULLUP); | |
} | |
void loop() | |
{ | |
while (digitalRead(C) == LOW) | |
{ | |
tone(8, NOTE_C4); | |
} | |
while (digitalRead(D) == LOW) | |
{ | |
tone(8, NOTE_D4); | |
} | |
while (digitalRead(E) == LOW) | |
{ | |
tone(8, NOTE_E4); | |
} | |
while (digitalRead(F) == LOW) | |
{ | |
tone(8, NOTE_F4); | |
} | |
while (digitalRead(G) == LOW) | |
{ | |
tone(8, NOTE_G4); | |
} | |
while (digitalRead(A) == LOW) | |
{ | |
tone(8, NOTE_A4); | |
} | |
while (digitalRead(B) == LOW) | |
{ | |
tone(8, NOTE_B4); | |
} | |
noTone(8); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment