Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: 1Sheeld No Y Axis via iPhone8 #123514
    avatarAtu2
    Participant

    I did not see my attached code so adding it here. I’m new and not familiar. Hope this come out right.

    #include <Servo.h>
    #include <OneSheeld.h>

    Servo myservo1;
    Servo myservo2;
    Servo myservo4;
    Servo myservo5;
    Servo myservo6;

    void setup()
    {
    OneSheeld.begin();

    myservo1.attach(3);
    myservo1.write(0);
    myservo2.attach(5);
    myservo2.write(0);

    analogWrite(6, 200);
    analogWrite(9, 200);
    // myservo4.attach(9);
    // myservi4.write(90);

    myservo5.attach(10);
    myservo5.write(70);
    myservo6.attach(11);
    myservo6.write(10);
    }
    void loop() {

    if (ProximitySensor.getValue() > 0)
    myservo6.write(120);
    else
    myservo6.write(10);

    if (OrientationSensor.getX() > 0 && OrientationSensor.getX() <= 180)
    myservo1.write(map(abs(OrientationSensor.getX()), 0,180,180,0));

    if (OrientationSensor.getY() < -90 && OrientationSensor.getY() >= -180)
    {
    myservo2.write(map(abs(OrientationSensor.getY()),180,90,0,90));
    }

    if (OrientationSensor.getZ() > 0 && abs(OrientationSensor.getZ()) <= 60)
    myservo5.write(map(OrientationSensor.getZ(),0,60,70,100));

    if (OrientationSensor.getZ() < 0 && abs(OrientationSensor.getZ()) <= 60)
    myservo5.write(map(abs(OrientationSensor.getZ()),60,0,0,70));

    OneSheeld.processInput();
    }

Viewing 1 post (of 1 total)