Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. // Define controllers/triggers by pin
  2. const int buttonPin = 3;
  3. const int ledPin = 5; //Define LED pin at 5
  4. const int dialPin = A0;
  5. const int joyStickX = A2;
  6. const int joyStickY = A3;
  7.  
  8. int buttonState = 0;
  9. int dialval = 0;
  10. int joyXval = 0.45; // halfway point of values (joystick resting position)
  11. int joyYval = 5;
  12.  
  13. void setup() {
  14. // initialise digital pin
  15. pinMode(buttonPin, INPUT);
  16. pinMode(ledPin, OUTPUT);
  17.  
  18. Serial.begin(9600);
  19. }
  20.  
  21. void loop() {
  22. // read the value/state of the controller/triggers
  23. buttonState = digitalRead(buttonPin); // button on or off
  24. {
  25. dialVal = analogRead(dialPin);
  26. dialVal = map(dialVal, 0, 1023, 0, 127); // scale to max
  27. }
  28. joyXval = analogRead(joyStickX);
  29. joyXval = map(joyXval, 0, 1023, 0, 0.9);
  30. joyYval = analogRead(joyStickY);
  31. joyYval = map(joyYval, 0, 1023, 0, 10);
  32.  
  33.  
  34. //check buttonState
  35. if (buttonState == HIGH) {
  36. digitalWrite(ledPin, HIGH); // turn LED on
  37. Serial.print(buttonState);
  38. digitalWrite(ledPin, LOW);
  39. } else {
  40. // turn LED off
  41. digitalWrite(ledPin, LOW);
  42. Serial.print(buttonState);
  43. }
  44.  
  45. // Read analog values
  46. Serial.print(" ");
  47. Serial.print(dialVal);
  48. Serial.print(" ");
  49. Serial.print(joyXval);
  50. Serial.print(" ");
  51. Serial.print(joyXval);
  52.  
  53. Serial.println();
  54. }
  55.  
  56. /Volumes/SANDISK-32/Music_Tech_Synth_Arduino_Code/Music_Tech_Synth_Arduino_Code.ino: In function 'void loop()':
  57. Music_Tech_Synth_Arduino_Code:27:3: error: 'dialVal' was not declared in this scope
  58. dialVal = analogRead(dialPin);
  59.  
  60. ^
  61. Music_Tech_Synth_Arduino_Code:49:16: error: 'dialVal' was not declared in this scope
  62. Serial.print(dialVal);
  63. ^
  64. exit status 1
  65. 'dialVal' was not declared in this scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement