601 | | |
| 601 | {{{ |
| 602 | void setup() { |
| 603 | pinMode(3, INPUT); |
| 604 | pinMode(4, OUTPUT); |
| 605 | pinMode(5, OUTPUT); |
| 606 | pinMode(6, OUTPUT); |
| 607 | pinMode(7, OUTPUT); |
| 608 | pinMode(8, OUTPUT); |
| 609 | pinMode(9, OUTPUT); |
| 610 | pinMode(10, OUTPUT); |
| 611 | pinMode(11, OUTPUT); |
| 612 | digitalWrite(3, HIGH); |
| 613 | digitalWrite(4, LOW); |
| 614 | digitalWrite(5, LOW); |
| 615 | digitalWrite(6, LOW); |
| 616 | digitalWrite(7, LOW); |
| 617 | digitalWrite(8, LOW); |
| 618 | digitalWrite(9, LOW); |
| 619 | digitalWrite(10, LOW); |
| 620 | digitalWrite(11, LOW); |
| 621 | Serial.begin(9600); |
| 622 | |
| 623 | |
| 624 | } |
| 625 | |
| 626 | void loop() { |
| 627 | // put your main code here, to run repeatedly: |
| 628 | int val_x = analogRead(0); |
| 629 | int val_y = analogRead(1); |
| 630 | int input1 = digitalRead(3); |
| 631 | Serial.print("sw: "); |
| 632 | Serial.print(input1); |
| 633 | Serial.print(" x: "); |
| 634 | Serial.print(val_x); |
| 635 | Serial.print(" y: "); |
| 636 | Serial.println(val_y); |
| 637 | |
| 638 | |
| 639 | if ( 0 <=val_x && val_x < 128) |
| 640 | { |
| 641 | // Serial.println(" range 1"); |
| 642 | digitalWrite(4, HIGH); |
| 643 | digitalWrite(5, LOW); |
| 644 | digitalWrite(6, LOW); |
| 645 | digitalWrite(7, LOW); |
| 646 | digitalWrite(8, LOW); |
| 647 | digitalWrite(9, LOW); |
| 648 | digitalWrite(10, LOW); |
| 649 | digitalWrite(11, LOW); |
| 650 | |
| 651 | } |
| 652 | if ( 128 <=val_x && val_x < 256) |
| 653 | { |
| 654 | // Serial.println(" range 2"); |
| 655 | digitalWrite(4, HIGH); |
| 656 | digitalWrite(5, HIGH); |
| 657 | digitalWrite(6, LOW); |
| 658 | digitalWrite(7, LOW); |
| 659 | digitalWrite(8, LOW); |
| 660 | digitalWrite(9, LOW); |
| 661 | digitalWrite(10, LOW); |
| 662 | digitalWrite(11, LOW); |
| 663 | } |
| 664 | if ( 256 <=val_x && val_x < 384) |
| 665 | { |
| 666 | // Serial.println(" range 3"); |
| 667 | } |
| 668 | if ( 384 <=val_x && val_x < 512) |
| 669 | { |
| 670 | // Serial.println(" range 4"); |
| 671 | } |
| 672 | if ( 512 <=val_x && val_x < 640) |
| 673 | { |
| 674 | // Serial.println(" range 5"); |
| 675 | } |
| 676 | if ( 640 <=val_x && val_x < 768) |
| 677 | { |
| 678 | // Serial.println(" range 6"); |
| 679 | } |
| 680 | if ( 768 <=val_x && val_x < 896) |
| 681 | { |
| 682 | // Serial.println(" range 7"); |
| 683 | } |
| 684 | if ( 896 <=val_x && val_x < 1024) |
| 685 | { |
| 686 | // Serial.println(" range 8"); |
| 687 | } |
| 688 | |
| 689 | |
| 690 | delay(300); |
| 691 | |
| 692 | } |
| 693 | }}} |