With just a few components, you can follow the approach of a 1-axle Robot controlled by your smartphone.
We are around 15 euros here, the robot is simply put together and can be expanded with additional components.
This construct is often available as a kit in the Far East. My challenge was control with an iPhone, which led me to a BLE HM-10.
The sketch was taken from DFRobot (product: Motor Shield DRI0001) and worked right away. I have raised the PWM values a little so that the wheels turn powerfully.
case 'w'://Move ahead
Motor1(200, true); //You can change the speed, such as Motor(50,true)
Motor2(200, true);
break;
To prevent the vehicle from tipping over, a variable tire is permanently attached at the front. The two motors are each attached to the motor shield and the bluetooth HM-10 also to the motor shield (RX / TX). Note that RX is led from the ble module to the TX of the motor shield and TX to RX.
After the sketch is flashed on the arduino, the curious makers will try the control via Arduino IDE - Serial Monitor and the transmission of "w" for sure: you will be disappointed that it is not enough with the usb cable (which provides 5V). So connect a 9V battery - then it works right away.
Connects your smartphone - from the HM-10 it can also be an iphone - with the ble component and try out the letters available in the sketch (within the loop).I suggest the free Serial Light app to transmit the letters:
Have fun assembling and have a nice Christmas 2020.
Update 30.03.2020 - Run motor runWith this motor shield you can also operate small DC motors up to 12V:
here is an example from the removed Canon printer.
//This motor shield use Pin 6,5,7,4 to control the motor
// Simply connect your motors to M1+,M1-,M2+,M2-
// Upload the code to Arduino/Roboduino
// Through serial monitor, type 'a','s', 'w','d','x' to control the motor
// www.dfrobot.com
// Last modified on 24/12/2009
int EN1 = 5;
//int EN2 = 6; //Roboduino Motor shield uses Pin 9
int IN1 = 4;
//int IN2 = 7; //Latest version use pin 4 instead of pin 8
void Motor1(int pwm, boolean reverse) {
analogWrite(EN1, pwm); //set pwm control, 0 for stop, and 255 for maximum speed
if (reverse) {
digitalWrite(IN1, HIGH);
}
else {
digitalWrite(IN1, LOW);
}
}
/*
void Motor2(int pwm, boolean reverse) {
analogWrite(EN2, pwm);
if (reverse) {
digitalWrite(IN2, HIGH);
}
else {
digitalWrite(IN2, LOW);
}
}
*/
void setup() {
int i;
// for(i=6;i<=9;i++) //For Roboduino Motor Shield
// pinMode(i, OUTPUT); //set pin 6,7,8,9 to output mode
for (i = 4; i <= 7; i++) //For Arduino Motor Shield
pinMode(i, OUTPUT); //set pin 4,5,6,7 to output mode
Serial.begin(9600);
}
void loop() {
int x, delay_en;
char val;
while (1) {
val = Serial.read();
if (val != -1) {
switch (val) {
case 'w'://Move ahead
Motor1(255, true); //You can change the speed, such as Motor(50,true)
//Motor2(100, true);
break;
case 'x'://move back
Motor1(255, false);
//Motor2(100, false);
break;
case 's'://stop
Motor1(0, false);
//Motor2(0, false);
break;
}
}
}
}
Comments
Please log in or sign up to comment.