element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Arduino
  • Products
  • More
Arduino
Arduino Forum remote controlled car problem
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 5 replies
  • Subscribers 117 subscribers
  • Views 107 views
  • Users 0 members are here
  • coding
  • maker
  • pins
  • connect
  • help
  • control
  • b
  • separate
  • pot
  • servo
  • code
  • not
  • electrical
  • motor
  • arduino
  • analog
  • remote
  • j
Related

remote controlled car problem

dirtdiver
dirtdiver over 10 years ago

Hello everyone, here is the problem :

I'm making a remote control truck with the Arduino but the analog pins are just not enough.I have 2 analog pins left and I have to control 4 servos with potentiometers.

 

Now, my idea is to use the 1st pin for a pot that is separatet into 4 sections.Each section will connect the pot from the 2nd analog pin to servos 1-4.

I dont know if that is possible so please tell me if I can do that and how to do it.

Also if you can think of something else that solves my problem, feel free to share it!

Thanks for the help!

  • Reply
  • Cancel
  • Cancel

Top Replies

  • Former Member
    Former Member over 10 years ago +1 verified

    i did a similar build for a tech fair wat scale are you aiming for do you want full motor control or just partial

  • Former Member
    Former Member over 10 years ago in reply to dirtdiver +1

    In your "if" condition, do you mean to check the analogRead value of potpin1, instead of just the value of potpin1 (which is always set to 1), like so:

     

    if (analogRead(potpin1) > 500){

  • Former Member
    0 Former Member over 10 years ago

    i did a similar build for a tech fair wat scale are you aiming for do you want full motor control or just partial

    • Cancel
    • Up +1 Down
    • Reply
    • Reject Answer
    • Cancel
  • dirtdiver
    0 dirtdiver over 10 years ago in reply to Former Member

    Well here's what I've wrote so far, you will get the idea of what Im tring to do.The code is not working and I dont really know why

     

    Servo myservo;  // create servo object to control a servo
    Servo myservo1;

    int potpin1 = 0;  // analog pin used to connect the potentiometer
    int potpin = 1;
    int val;    // variable to read the value from the analog pin

    void setup()
    {
      myservo.attach(9);  // attaches the servo on pin 9 to the servo object
    myservo1.attach(10);
    }

    void loop()
    {
      if (potpin1 > 500){
       val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
      myservo.write(val);                  // sets the servo position according to the scaled value
      delay(15);
      } else  {
      val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
      myservo1.write(val);                  // sets the servo position according to the scaled value
      delay(15);
      }
    }

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to dirtdiver

    In your "if" condition, do you mean to check the analogRead value of potpin1, instead of just the value of potpin1 (which is always set to 1), like so:

     

    if (analogRead(potpin1) > 500){

    • Cancel
    • Up +1 Down
    • Reply
    • Verify Answer
    • Cancel
  • dirtdiver
    0 dirtdiver over 10 years ago in reply to Former Member

    Thanks man, it worked when i changed it!

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago

    If you want to use one servo at one time this can be solve

    divide potentiometer reading into  4 parts on each part use one servo motor

    and map each part in the if block seperatly in the defined range..

     

    for eg

    analogread(val)

    0-255 1st motor

    255-512 2nd motor

    512-767 3rd

    767-1023 4th

    and map them

     

    for eg

    2nd one as

    map(val,255,512,0,179)

    and so on...

    • Cancel
    • Up 0 Down
    • Reply
    • Verify Answer
    • Cancel
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube