Created
December 15, 2022 02:19
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
// constants won't change. They're used here to set pin numbers: | |
#define but1 12 // the number of the pushbutton pin | |
#define but2 10 // the number of the pushbutton pin | |
#define but3 8 // the number of the pushbutton pin | |
#define but4 6 // the number of the pushbutton pin | |
#define but5 4 // the number of the pushbutton pin | |
#define speak1 A5 | |
#define speak2 A7 | |
/*Arduino: | |
tone(unsigned int pin, unsigned int frequency); | |
Volume: | |
vol.tone(unsigned int frequency, byte volume);*/ | |
/*#define NOTE_A2 110 | |
#define NOTE_B2 123 | |
#define NOTE_C3 131 | |
#define NOTE_D3 147 | |
#define NOTE_E3 165*/ | |
//notes | |
#define A 110 | |
#define B 123 | |
#define C 131 | |
#define D 147 | |
#define E 165 | |
// variables will change: | |
int state1 = 0; // variable for reading the pushbutton status | |
int state2 = 0; // variable for reading the pushbutton status | |
int state3 = 0; // variable for reading the pushbutton status | |
int state4 = 0; // variable for reading the pushbutton status | |
int state5 = 0; // variable for reading the pushbutton status | |
int sensorPin = A0; // select the input pin for the potentiometerLED | |
int sensorValue = 0; // variable to store the value coming from the sensor | |
int printCount = 0; // print repetitions, dependant on flex sensor | |
// the setup function runs once when you press reset or power the board | |
void setup() { | |
// initialize the LED pin as an output: | |
//pinMode(ledPin, OUTPUT); | |
// initialize the pushbutton pin as an input: | |
pinMode(but1, INPUT); | |
pinMode(but2, INPUT); | |
pinMode(but3, INPUT); | |
pinMode(but4, INPUT); | |
pinMode(but5, INPUT); | |
//pinMode(speak1, OUTPUT); | |
//pinMode(speak2, OUTPUT); | |
Serial.begin(9600); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
/*tone(buzz, 31, 20); | |
tone(buzz, 98, 20); | |
tone(buzz, 147, 20); | |
Serial.println("buzzed");*/ | |
//noTone(2); | |
/*sensorValue = analogRead(sensorPin); | |
//Serial.println(sensorValue); | |
printCount = map(sensorValue, 20, 300, 1, 10);*/ | |
tone(speak1, 440, 1); | |
//tone(speak2, 440, 1); | |
/* | |
// read the state of the pushbutton value: | |
state1 = digitalRead(but1); | |
state2 = digitalRead(but2); | |
state3 = digitalRead(but3); | |
state4 = digitalRead(but4); | |
state5 = digitalRead(but5); | |
//testing flex sensor | |
//Serial.println(sensorValue); | |
//Serial.println(printCount); | |
//button 1 | |
if (state1 == HIGH) { | |
//Serial.println(printCount); | |
Serial.println("1"); | |
tone(speak1, A, 5); | |
tone(speak2, A, 5); | |
} | |
//button 2 | |
if (state2 == HIGH) { | |
Serial.println("2"); | |
tone(speak1, B, 5); | |
tone(speak2, B, 5); | |
} | |
//button 3 | |
if (state3 == HIGH) { | |
Serial.println("3"); | |
tone(speak1, C, 5); | |
tone(speak2, C, 5); | |
} | |
//button 4 | |
if (state4 == HIGH) { | |
Serial.println("4"); | |
tone(speak1, D, 5); | |
tone(speak2, D, 5); | |
} | |
//button 5 | |
if (state5 == HIGH) { | |
Serial.println("5"); | |
tone(speak1, E, 5); | |
tone(speak2, E, 5); | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment