Advertisement
lukeproductions

Code

Nov 22nd, 2019
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myservo;
  4.  
  5. int ServoPin = 9; //the servo signal pin
  6. int SoundInPin = A0; //the audio in pin
  7.  
  8. void setup() {
  9.  
  10.   myservo.attach(ServoPin);
  11.   pinMode(SoundInPin, INPUT);
  12.  
  13. }
  14.  
  15. void loop() {
  16. int intensity = analogRead(SoundInPin);
  17.  
  18. intensity = map(sensorValue,0,60,0,180); //change the x in the            intensity = map(sensorValue,0,x,0,180);       //it is used for sensitivity
  19. 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
  20. myservo.write(0);
  21.  
  22. int MoveDelayValue = map(sensorValue,0,255,0,sensorValue);
  23.  
  24. if (sensorValue > 33) {
  25.    delay(1);  
  26.    myservo.write(sensorValue);
  27.    delay(MoveDelayValue);
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement