My little device plays 4 different notes, (one when each of the buttons is pressed). I initially tried to write a program in which a tone would be played depending on the number of consecutive buttons pressed, but I found that difficult to work with> it also did not have the functionality i wanted. I researched online about how to make each function work, then slowly stitched it together. I programmed the notes, bu looking up how many Hertz each of my desired notes was, and plugging it into the program.
const int buttonPin1 = 2; const int buttonPin2 = 3; const int buttonPin3 = 4; const int buttonPin4 = 5;// the number of the pushbutton pin int Buzzer1 = 6; int Buzzer2 = 7; int Buzzer3 = 8; int Buzzer4 = 9; int led1 = 10; int led2 = 11; int led3 = 12; int led4 = 13; int led4State = LOW; // variables will change: int buttonState1 = 0; int buttonState2 = 0; int buttonState3 = 0; int buttonState4 = 0; // variable for reading the pushbutton status void setup() { // initialize the piezo as output: pinMode(Buzzer1, OUTPUT); pinMode(Buzzer2, OUTPUT); pinMode(Buzzer3, OUTPUT); pinMode(Buzzer4, OUTPUT); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); pinMode(buttonPin3, INPUT); pinMode(buttonPin4, INPUT); } void loop() { // read the state of the pushbutton value: int buttonState1 = digitalRead(buttonPin1); int buttonState2 = digitalRead(buttonPin2); int buttonState3 = digitalRead(buttonPin3); int buttonState4 = digitalRead(buttonPin4); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState4 == LOW) { noTone(Buzzer1); digitalWrite(led4, LOW); } else if (buttonState4 == HIGH) { //digitalWrite(led2, LOW); digitalWrite(led4, HIGH); tone(Buzzer1, 261); } if (buttonState3 == LOW) { noTone(Buzzer2); digitalWrite(led3, LOW); } else if (buttonState3 == HIGH) { //digitalWrite(led2, LOW); digitalWrite(led3, HIGH); tone(Buzzer2, 349); } if (buttonState2 == LOW) { noTone(Buzzer3); digitalWrite(led2, LOW); } else if (buttonState2 == HIGH) { //digitalWrite(led2, LOW); digitalWrite(led2, HIGH); tone(Buzzer3, 392); } if (buttonState1 == LOW) { noTone(Buzzer4); digitalWrite(led1, LOW); } else if (buttonState1 == HIGH) { //digitalWrite(led2, LOW); digitalWrite(led1, HIGH); tone(Buzzer4, 440); }
Also, my post about the reading:
Despite initially finding myself strongly disagreeing with the author’s definition of Interactivity, I eventually found myself drawn in by his argument. The author has a very specific definition of interactivity: a cyclic process in which two actors alternately listen, think, and speak. In other words, in his eyes at least, an interaction is like a conversation. He then proceeds to explain that a person cannot have a conversation with an object that does not speak back in any way, does not think, or cannot listen. (The way he says this is rather cheeky, and his self-importance gets on my nerves, but I’ll let it slide). He discusses variability in the level of interactivity a thing can have. The line that won me over was “How many times has your heart protested as you watched the protagonist in a movie do something disastrous?” I related to my lack of ability to have a conversation with a movie. That being said, I believe the author’s definition, as he defines it, is valid.
Here is a cheeky little picture I found one time that reminded me of the reading 🙂