Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo;
- int ServoPin = 9; //the servo signal pin
- int SoundInPin = A0; //the audio in pin
- void setup() {
- myservo.attach(ServoPin);
- pinMode(SoundInPin, INPUT);
- }
- void loop() {
- int intensity = analogRead(SoundInPin);
- intensity = map(sensorValue,0,60,0,180); //change the x in the intensity = map(sensorValue,0,x,0,180); //it is used for sensitivity
- intensity = sensorValue *1.25; //change the y in the intensity = sensorValue *y //the biggest the number is the more will the nutcracker open its mouth
- myservo.write(0);
- int MoveDelayValue = map(sensorValue,0,255,0,sensorValue);
- if (sensorValue > 33) {
- delay(1);
- myservo.write(sensorValue);
- delay(MoveDelayValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement