SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By Zackbare
#195415
I bought a kit from a local company in India and list of components available with me is attached below. I'll be powering arduino with standard 9v battery. So I want to drive two motors from a Canon printer with 4*4v-1Ah batteries (pic attached) which obviously can't run with a H-bridge so I found the alternate which is Motor Shield, but I can't afford the arduino rev3 as I'll have to import that and other s use up all the pins which is not good so I found this(link below).
Also for using it with WiFi I either can use Ethernet shield (with a Pocket router and custom made webpage) or WiFi card (Idk which)(links below).
Amazon links- https://www.amazon.in/gp/aw/d/B00AXVX5D ... UIOPHJ56Y3
https://www.amazon.in/gp/aw/d/B01M6U29U ... 9VL3TSHL8J
https://www.amazon.in/gp/aw/d/B019IJ8EC ... F6BJA0G125
Will these work together?
Also attached below is the GPIO extension IDK how to use it.
Code to my current progress is below, where I've used PS2 stick, LCD, H bridge and servo (wired connection).
Link to pics - https://goo.gl/photos/pBL4ruVn5tkFrHASA https://goo.gl/photos/5aQgxZqmF2WaV1749
Avail stuff with me - https://goo.gl/photos/1fuQdE4SyeYEZSu16






Code -
include <Servo.h>

Servo myservo;
include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 10, 11, 12, 13); int JoyStick_X = 0; int JoyStick_Y = 1; int JoyStick_Z = 1;
int dir1PinA = 2; int dir2PinA = 3; int speedPinA = 6;
int dir1PinB = 4; int dir2PinB = 5; int speedPinB = 7;
int LowSpeed = 100; int MedSpeed = 170; int HighSpeed = 255;
void setup(void) { myservo.attach(17);
lcd.begin(16, 2); lcd.clear(); pinMode(JoyStick_Z, INPUT_PULLUP);
Serial.begin(9600);
pinMode(dir1PinA, OUTPUT); pinMode(dir2PinA, OUTPUT); pinMode(speedPinA, OUTPUT); pinMode(dir1PinB, OUTPUT); pinMode(dir2PinB, OUTPUT); pinMode(speedPinB, OUTPUT); }
void loop(void) {
int x, y, z; x = analogRead(JoyStick_X); y = analogRead(JoyStick_Y); z = digitalRead(JoyStick_Z);
lcd.setCursor(0, 0); lcd.print("Car Status");
lcd.setCursor(0, 1); lcd.print("Spd:"); if (z == 0) { lcd.print("High"); } else if (x > 510 && x < 530) { lcd.print("No "); } else if (x > 530 && x < 730) { lcd.print("Low "); } else if (x > 730) { lcd.print("Med "); } else if (x < 510 && x > 250) { lcd.print("RLow"); } else if (x < 250) { lcd.print("RMed"); }
lcd.print(" "); lcd.setCursor(10, 1); lcd.print("Trn:"); if (y < 500) { lcd.print("L "); } else if (525 > y && y > 500) { lcd.print("-"); } else if (y > 525) { lcd.print("R "); } lcd.setCursor(11, 0); lcd.print("Bst:"); if (z == 0) { lcd.print("Y"); } else { lcd.print("N"); }
//________________Motor 1________________________ if (z == 0 && x > 10) { // Motor Forward High analogWrite(speedPinA, HighSpeed); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); analogWrite(speedPinB, HighSpeed); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); } else if (x > 530 && x < 730) {// Motor Forward Low analogWrite(speedPinA, LowSpeed);//Sets speed variable via PWM digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); analogWrite(speedPinB, LowSpeed);//Sets speed variable via PWM digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); }
else if (x > 730) {// Motor Forward Med analogWrite(speedPinA, MedSpeed); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); analogWrite(speedPinB, MedSpeed); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); }
else if (x > 510 && x < 530) {// Motor Stop analogWrite(speedPinA, 0); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); analogWrite(speedPinB, 0); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); }
else if (x < 510 && x > 250) { // Motor Reverse Low analogWrite(speedPinA, LowSpeed); digitalWrite(dir1PinA, HIGH); digitalWrite(dir2PinA, LOW); analogWrite(speedPinB, LowSpeed); digitalWrite(dir1PinB, HIGH); digitalWrite(dir2PinB, LOW); }
else if (x < 250 && x > 0) { // Motor Reverse Med analogWrite(speedPinA, MedSpeed); digitalWrite(dir1PinA, HIGH); digitalWrite(dir2PinA, LOW); analogWrite(speedPinB, MedSpeed); digitalWrite(dir1PinB, HIGH); digitalWrite(dir2PinB, LOW); }
myservo.write(40 + y * 8.7890625 / 100);
By Valen
#195458
Zackbare wrote:I bought a kit from a local company in India and list of components available with me is attached below. I'll be powering arduino with standard 9v battery. So I want to drive two motors from a Canon printer with 4*4v-1Ah batteries (pic attached) which obviously can't run with a H-bridge...
Why not? 2, 3 or 4 times 4 volt in series should be enough to make the motor run with an H-bridge.
so I found the alternate which is Motor Shield, but I can't afford the arduino rev3 as I'll have to import that and other s use up all the pins which is not good so I found this(link below).
That motorshield is also an H-bridge in a Arduino (Uno) shield formfactor. What makes the rev 3 Uno so special? What do you have now that is different from a rev 3? (and makes it insufficient)
Also for using it with WiFi I either can use Ethernet shield (with a Pocket router and custom made webpage)
Ethernet is with a cable. A stiff network-cable is not very practical with a car that is running around. How does an ethernet cable connection pick up Wifi signals? What's a "pocket router"? Can you give an example of what you intend to use?
or WiFi card (Idk which)(links below).
Amazon links- https://www.amazon.in/gp/aw/d/B00AXVX5D ... UIOPHJ56Y3
https://www.amazon.in/gp/aw/d/B01M6U29U ... 9VL3TSHL8J
https://www.amazon.in/gp/aw/d/B019IJ8EC ... F6BJA0G125
Will these work together?
"Chipdot 3-01-0441-2 Ethernet W5100 Shield" with "NRF24L01+ 2.4GHZ WIFI Wireless Transceiver module for Arduino"? No, again, one is cable, the other wireless. But not wireless as in Wifi. NRF24L01+ uses a different protocol.

There are plenty examples for Arduino getting 2 NRF24L01+ modules working together. But that won't connect to your PC, smartphone or a webserver if that is desired. 2 arduino or other microcontrollers are needed to control them over SPI interface.

"Chipdot 3-01-0441-2 Ethernet W5100 Shield" with "L298P Motor Shield motor driver for arduino"? The the SPI interface for the ethernetshield it likely uses D4 for slave/chip-select. I don't know for sure, the Amazon description isn't very clear. But there are other ethernet shields that have this also. This will likely conflict with the control pins needed for the Motorshield (D4-D7). Since it is a single pin it might be possible to use a different pin for slave-select and hack/jumperwire the ethernet shield a bit.

But why bother with ethernetshields? A ESP8266 chip based wifi solution is generally much cheaper and has wifi. So much more mobile for your RC car. The link you showed offers the shield (I'm not suggesting to buy it, only important for price comparison. I don't know what currency that is) with a basic ESP-01 module for nearly the same price It needs a 3.3 volt supply for power and some protection parts to safely connect it to a 5 volt Arduino. But that seems alot less pricy and makes your car more mobile. (not to mention lighter)
Also attached below is the GPIO extension IDK how to use it.
Not sure which picture or link that should be. But I don't know either. Why buy it then?
Code to my current progress is below, where I've used PS2 stick, LCD, H bridge and servo (wired connection).
Please post that in-between
Code: Select all
 [/ code] tags to make it display neater in the thread. As it turns out that code will not compile because some spaces are missing between words. The formatting also makes it unreadable.