• 0

Arduino motor shield rev3 : the first approach running a dc-motor (without a library)


Question

hello dear experts good day .

 

 

well first of all - i want to express that i am not 100% sure if this belongs to this forum - or to the hardware forum. (as it covers a arduino-question)

 

I have buyes a arduino motor shield rev3 (revision 3) see the page where it is being sold:  https://store.arduino.cc/arduino-motor-shield-rev3 When I follow the link for "Getting Started section" the page lists a lot of shields but not the motor shield. I am looking for a library for the motor board - or at least for an first approach to get the thing up and running. 
What is aimed: I'm trying to drive 2 DC motors - for a rc-car.  Therefore i have connected two DC Servo Motors to the Motor Shield and wrote the following sequence:

 


 void setup() 
    {
      //Setup Channel A
      pinMode(12, OUTPUT);     //Initiates Motor Channel A pin
      pinMode(9, OUTPUT);      //Initiates Brake Channel A pin

      //Setup Channel B
      pinMode(13, OUTPUT);     //Initiates Motor Channel A pin
      pinMode(8, OUTPUT);      //Initiates Brake Channel A pin
    }


and afterwards we have the following piece of code: 

 

 

    void loop()
    {
      //Phase 1 - going to the wall
      //Motor A forward - Max Speed
      digitalWrite(12, LOW);   //this should try to establishes forward direction of Channel A
      digitalWrite(9, LOW);    //this is for the Disengage of the Brake for Channel A
      analogWrite(3, 255);     //this should help to spin the motor on Channel A at max speed

      //Motor B forward - Max Speed
      digitalWrite(13, HIGH);  //this is to establish forward direction of Channel B
      digitalWrite(8, LOW);    //this should help to disengage the brake for Channel B
      analogWrite(11, 255);    //this spins the motor on channel B at max speed

      delay(4000); // Adjust to correspond the distance

  //Phase 2 - getting back to initial point
  //Motor A backward - max speed
  digitalWrite(12, HIGH);  // this should establish backward direction of Channel A
  digitalWrite(9, LOW);    //now we need to disengage the Brake for Channel A
  analogWrite(3, 255);     //at this point i want to spins the motor on Channel A at max speed

  //Motor B backward - max speed
  digitalWrite(13, LOW);   // right now i try to establishes backward direction of Channel B
  digitalWrite(8, LOW);    //and now we want to disengage the Brake for Channel B
  analogWrite(11, 255);    //finally we want to spins the motor on Channel B at max speed

  delay(4000);

  //Phase 3 Stop for 7.5 seconds
  // Motor A stop
  digitalWrite(9, HIGH);   // here we try to engage the Brake for Channel A
    //Motor B 


 

 

what happens now While connected to USB, the device executes perfectly the sequence.

but wait: whein i run the sequence using the DC Source, the device does not respect any part of the coding. 
It started simply going forward while then it wante to  reverse the polarity randomly blocking the movement sometimes.


i afterwards tried another approach as a library-replacement i have tried this code is simple enough:

 

 

void setup() {

  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin

}

void loop(){

  //forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed

  delay(3000);

  digitalWrite(9, HIGH); //Engage the Brake for Channel A
}

 

conclusio: Well - what is very very funny - with the second code-example it runs like a charme.

 

Looking forward to your suggestions.

Edited by tarifa

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • While I agree with all that, it just proves there's an a** built for every seat.
    • Lol are you mad because I'm not using AI? I'd rather pay people than lose a bunch of potential customers and get humilated because I used AI. A lot of people won't purchase a game if it used AI during development.
    • LibreWolf 152.0-1 by Razvan Serea LibreWolf is an independent “fork” of Firefox, with the primary goals of privacy security and user freedom. It is the community run successor to LibreFox. LibreWolf is designed to increase protection against tracking and fingerprinting techniques, while also including a few security improvements. This is achieved through our privacy and security oriented settings and patches. LibreWolf also aims to remove all the telemetry, data collection and annoyances, as well as disabling anti-freedom features like DRM. LibreWolf features: Latest Firefox — LibreWolf is compiled directly from the latest build of Firefox Stable. You will have the the latest features, and security updates. Independent Build — LibreWolf uses a build independent of Firefox and has its own settings, profile folder and installation path. As a result, it can be installed alongside Firefox or any other browser. No phoning home — Embedded server links and other calling home functions are removed. In other words, minimal background connections by default. User settings updates Extensions firewall: limit internet access for extensions. Multi-platform (Windows/Linux/Mac/and soon Android) Community-Driven Dark theme (classic and advanced) LibreWolf privacy features: Delete cookies and website data on close. Include only privacy respecting search engines like DuckDuckGo and Searx. Include uBlockOrigin with custom default filter lists, and Tracking Protection in strict mode, to block trackers and ads. Strip tracking elements from URLs, both natively and through uBO. Enable dFPI, also known as Total Cookie Protection. Enable RFP which is part of the Tor Uplift project. RFP is considered the best in class anti-fingerprinting solution, and its goal is to make users look the same and cover as many metrics as possible, in an effort to block fingerprinting techniques. Always display user language as en-US to websites, in order to protect the language used in the browser and in the OS. Disable WebGL, as it is a strong fingerprinting vector. Prevent access to the location services of the OS, and use Mozilla's location API instead of Google's API. Limit ICE candidates generation to a single interface when sharing video or audio during a videoconference. Force DNS and WebRTC inside the proxy, when one is being used. Trim cross-origin referrers, so that they don't include the full URI. Disable link prefetching and speculative connections. Disable disk cache and clear temporary files on close. Disable form autofill. Disable search and form history...and more. LibreWolf 152.0-1 changelog: Upstream release, see the Firefox 152.0 Release Notes Notable changes: The AppImages are now built on Codeberg along with the other releases We have decided to wait a bit longer to enable the settings redesign, due to use being aware of multiple upstream issues Download: LibreWolf 64-bit | Portable 64-bit | ~100.0 MB (Open Source) Download: ARM64 | Portable ARM64 Links: LibreWolf Home Page | Addons | Screenshot | Reddit Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • hahahahah wow hahahah you sure got me there hahahahahah, you know that bad performance is always due to poor optimization by the developers, right???
    • "I know for a fact I'll never own one of these." This is why choice is better than government regulation. Globaly Android has something like 72% of the smartphone market. Granted the vast majority of that is low end phones. Apple can and should charge whatever they want. The market will decide if it is too much.
  • Recent Achievements

    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
    • One Month Later
      eurospharma62 earned a badge
      One Month Later
    • Week One Done
      With What earned a badge
      Week One Done
    • Week One Done
      Harris Gilbert earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      560
    2. 2
      +Edouard
      168
    3. 3
      PsYcHoKiLLa
      72
    4. 4
      Michael Scrip
      64
    5. 5
      ATLien_0
      64
  • Tell a friend

    Love Neowin? Tell a friend!