Different step to follow :
- [1] Change the board for Arduino uno
- [2] Change the port for One of the proposal
- [3] If you change the code you can try to check the verifications
- [4] Televerser
- [5] You can check the informations with the little loupe in the right corner.
This exemple work with an Inpout : PHOTORESISTOR and an Outpout : 8 ohm speaker or piezo
Arduino Uno |
- | -
|
void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
}
void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
// to the output pitch range (120 - 1500Hz)
// change the minimum and maximum input numbers below depending on the range
// your sensor's giving:
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
// play the pitch:
tone(9, thisPitch, 10);
delay(1); // delay in between reads for stability
}
void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
}
void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
// to the output pitch range (120 - 1500Hz)
// change the minimum and maximum input numbers below depending on the range
// your sensor's giving:
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
// play the pitch:
tone(9, thisPitch, 10);
delay(1); // delay in between reads for stability
}