можно на бубажечках масенькие надписи сделать и скотчем приклеить к проводам
Добавлено спустя 40 секунд:
я понял, все так делают
кстати лучше не путать, в лучшем случае может как минимум не работать, в худшем может что и выгореть
roboforum.ruТехнический форум по робототехнике. |
|
|
|
Реклама | ||||
|
|
|||
Реклама | ||||
|
|
|||
/*
Analog Pin 0: microphone
Digital Pin 3: DC gear reduction motor attached to the lock. (Or a motor controller or a solenoid or other unlocking mechanisim.)
Digital Pin 5: Green LED.
*/
// Pin definitions
const int soundSensor = 0; // microphone on pin 0.
const int lockMotor = 3; // Gear motor used to turn the lock.
const int greenLED = 5; // Status LED
// Tuning constants. Could be made vars and hoooked to potentiometers for soft configuration, etc.
const int threshold = 550; // Minimum signal from the microphone to register as a sound.
const int soundFadeTime = 100; // milliseconds we allow a sound to fade before we listen for another one. (Debounce timer.)
const int lockTurnTime = 300; // milliseconds that we run the motor to get it to go a half turn.
// Variables.
int soundSensorValue = 0;
void setup() {
pinMode(lockMotor, OUTPUT);
pinMode(greenLED, OUTPUT);
Serial.begin(9600); // Uncomment the Serial.bla lines for debugging.
Serial.println("Program start."); // but feel free to comment them out after it's working right.
//digitalWrite(greenLED, HIGH); // Green LED on, everything is go.
}
// Records the sound.
void listenToSound(){
Serial.println("someone is blowing in");
}
// Runs the motor (or whatever) to turn the disc.
void triggerSpinDisc(){
Serial.println("Disc is spinning!");
// turn the motor on for a bit.
digitalWrite(lockMotor, HIGH);
digitalWrite(greenLED, HIGH); // And the green LED too.
delay (lockTurnTime); // Wait a bit.
digitalWrite(lockMotor, LOW); // Turn the motor off.
}
void stopDisc(){
Serial.println("disc is stopping");
delay(soundFadeTime);
digitalWrite(lockMotor, LOW);
digitalWrite(greenLED, LOW);
}
void loop() {
// Listen for any sound at all.
soundSensorValue = analogRead(soundSensor);
Serial.println(soundSensorValue);
if (soundSensorValue >=threshold){
listenToSound();
triggerSpinDisc();
} else {
stopDisc();
}
}
Вернуться в Arduino и другие Xduino
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 16