0%
0%

fullyanalog-programmer

A firmly-ground, yet constantly-evolving human being trying to figure things out.

Pale Blue Dot
Send a private message
Similar accounts worth following
fullyanalog-programmer
Send a private message

This user joined on 08/23/2015.

  • Yes-No Thing

    01/03/2016 at 21:58 0 comments

    An electronic excise and a table piece made for a themed party. A basic exercise in physical input-output using a servo logic. A breadboard with a servo, joystick, arduino nano, and a usb-to-serial adapter all sitting on a usb charger. A very short arduino code.

    //
    // Yes-No
    // wp
    //
    // arduino nano - servo - joystick
    //
    // servo input -> D2
    // joystick axis -> A1
    //
    #include <Servo.h>
    Servo myservo; // create servo object 
    int pos = 0; // servo position
    const int joyH = 1; // pin A1 for joystick axis
    void setup() {
     myservo.attach(2); // attaches the servo on pin D2 
     Serial.begin(9600);
    }
    void loop() {
     pos = analogRead(joyH); 
     pos = map(pos, 0, 1023, 0, 180); // rescale joystk value
     myservo.write(pos); // command the servo
     delay(15); // time for servo mvmt
    }

View page

Share this profile

Share

Bits

Log In/Sign up to comment

Become a Hackaday.io Member

Create an account to leave a comment. Already have an account? Log In.

Become cool instantly

like fullyanalog-programmer and many others

AltStyle によって変換されたページ (->オリジナル) /