Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ignition domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131

Deprecated: Return type of GD_WordPress_File_Iterator_Filter::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /dom953964/wp-content/plugins/wp_migration-master/classes/iterators.php on line 5

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the health-check domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131
Pitch Follower with On/Off Switch – Lara Grant

Pitch Follower with On/Off Switch

[code lang=”arduino” light=”true”]

// ProtoSnap
// switch on for pitch controlled by light

const int buttonPin = 2; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP);

}

void loop() {
//read the button and store it’s state in new variable
buttonState = digitalRead(buttonPin);
//Serial.println(buttonState);

// read the light sensor:
int sensorReading = analogRead(A6);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the pitch to the range of the analog input.
// change the minimum and maximum input numbers below
// depending on the range your sensor’s giving:
int thisPitch = map(sensorReading, 50, 0, 100, 1000);

// if button in pressed do this…
if (buttonState == LOW){

// play the pitch:
tone(7, thisPitch, 10);

delay(1); // delay in between reads for stability
}

}

[/code]

Leave a Reply