Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Define controllers/triggers by pin
- const int buttonPin = 3;
- const int ledPin = 5; //Define LED pin at 5
- const int dialPin = A0;
- const int joyStickX = A2;
- const int joyStickY = A3;
- int buttonState = 0;
- int dialval = 0;
- int joyXval = 0.45; // halfway point of values (joystick resting position)
- int joyYval = 5;
- void setup() {
- // initialise digital pin
- pinMode(buttonPin, INPUT);
- pinMode(ledPin, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- // read the value/state of the controller/triggers
- buttonState = digitalRead(buttonPin); // button on or off
- {
- dialVal = analogRead(dialPin);
- dialVal = map(dialVal, 0, 1023, 0, 127); // scale to max
- }
- joyXval = analogRead(joyStickX);
- joyXval = map(joyXval, 0, 1023, 0, 0.9);
- joyYval = analogRead(joyStickY);
- joyYval = map(joyYval, 0, 1023, 0, 10);
- //check buttonState
- if (buttonState == HIGH) {
- digitalWrite(ledPin, HIGH); // turn LED on
- Serial.print(buttonState);
- digitalWrite(ledPin, LOW);
- } else {
- // turn LED off
- digitalWrite(ledPin, LOW);
- Serial.print(buttonState);
- }
- // Read analog values
- Serial.print(" ");
- Serial.print(dialVal);
- Serial.print(" ");
- Serial.print(joyXval);
- Serial.print(" ");
- Serial.print(joyXval);
- Serial.println();
- }
- /Volumes/SANDISK-32/Music_Tech_Synth_Arduino_Code/Music_Tech_Synth_Arduino_Code.ino: In function 'void loop()':
- Music_Tech_Synth_Arduino_Code:27:3: error: 'dialVal' was not declared in this scope
- dialVal = analogRead(dialPin);
- ^
- Music_Tech_Synth_Arduino_Code:49:16: error: 'dialVal' was not declared in this scope
- Serial.print(dialVal);
- ^
- exit status 1
- 'dialVal' was not declared in this scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement