Hi, I am trying to connect a dc motor, rotary encoder, and battery to an Arduino Uno and Sainsmart L293D motor driver shield to power an autonomous car that will stop at a certain distance after having accelerated to a very high speed, but I've had a lot of trouble even connecting the devices, let alone programming.
The motor and battery are connected, but I can't figure out how to connect the encoder, linked here: Rotary Encoder 200 P/R - RobotShop
Also, are there a few general rules to follow that must be implemented in the code if you have a shield?
And should the library for the Adafruit V2 shield work for the sainsmart L293D shield too? Because I can't seem to find a library for the shield I have and the motor test that I got from the Adafruit V2 shield library did not even upload to the Arduino and said it could not connect to the COM1 port and had an "error compliling to Arduino Genuino Uno," even though I've seen on a few youtube videos that this library should work for this shield. Thank you.
And should the library for the Adafruit V2 shield work for the sainsmart L293D shield too? Because I can't seem to find a library for the shield I have
Look for a library which supports the L293 driver. This might help:
http://playground.arduino.cc/Main/AdafruitMotorShield
and the motor test that I got from the Adafruit V2 shield library did not even upload to the Arduino and said it could not connect to the COM1 port and had an "error compliling to Arduino Genuino Uno," even though I've seen on a few youtube videos that this library should work for this shield. Thank you.
This seems to be your actual problem, and it has nothing to do with the shield.
"could not connect to the COM1 port" means that your arduino is not connected via usb, or connected to a different com port. Select the right com port in the Arduino IDE menu.
"error compiling" means that your sketch either has programming errors in it, or it is missing required libraries.
Take it step by step:
- try to upload a simple blink sketch from the examples list in the IDE. If this works,
- Install the motorshield library and try to compile your motorshield sketch.
https://www.arduino.cc/en/Guide/Libraries
If this works,
- upload the motorshield sketch. If this works,
- connect the shield and test it.
Good luck
Thomas
Thank you for giving me a direction, I really appreciate it.
Additionally, I got past step 1, the light blinked, then I downloaded the Adafruit V2 Motor Shield Library here: Install Software | Adafruit Motor Shield V2 | Adafruit Learning System , and I then tried the "dc motor test" while I had a dc motor in M1, however, the IDE said "Error Compilinf for Arduino Genuino Uno" again, even after the light blinking test worked. How could this be? Thank you.
If you turn on verbose output in the IDE preferences, then the compiler will tell you which error it encountered. If you don't understand the error message, google for it, or post it here. (googling will be faster 
Thomas