Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
SG90 Micro-servo motor
DC motor (generic)
ANGEEK L293D Driver Shield
Software & Tools
Ios Dabble app
Project description
Code
4wd
arduino
You need to install two libraries to use it : - Adafruit motor shield library - Dabble
1#include <AFMotor.h> 2#include <Servo.h> 3 4#define CUSTOM_SETTINGS 5#define INCLUDE_GAMEPAD_MODULE 6#include <Dabble.h> 7 8AF_DCMotor motor(1); 9AF_DCMotor motor2(2); 10AF_DCMotor motor3(4); 11AF_DCMotor motor4(3); 12 13Servo myservo; 14 15 int vitesse = 0; 16 int directionval = 90; 17 18 void setup() 19{ 20 Serial.begin(250000); // make sure your Serial Monitor is also set at this baud rate. 21 Dabble.begin(9600,0,1); 22 23 myservo.attach(10); 24 25 motor.run(RELEASE); 26 motor2.run(RELEASE); 27 motor3.run(RELEASE); 28 motor4.run(RELEASE); 29 myservo.write(90); 30} 31 32void loop() 33{ 34 Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile. 35 36 if(GamePad.isLeftPressed()){ 37 if (directionval < 110){ 38 directionval++; 39 } 40 } 41 else if( GamePad.isRightPressed()){ 42 if (directionval > 70){ 43 directionval--; 44 } 45 } 46 else if(GamePad.isCirclePressed()){ 47 directionval = 90; 48 vitesse = 0; 49 motor.run(RELEASE); 50 motor2.run(RELEASE); 51 motor3.run(RELEASE); 52 motor4.run(RELEASE); 53 } 54 else if (GamePad.isCrossPressed()){ 55 if(vitesse < 255){ 56 vitesse += 5; 57 } 58 } 59 else if (GamePad.isSquarePressed() ){ 60 if(vitesse > 0){ 61 vitesse -= 5; 62 } 63 } 64 else if (GamePad.isUpPressed()) 65 { 66 motor.run(FORWARD); 67 motor2.run(FORWARD); 68 motor3.run(FORWARD); 69 motor4.run(FORWARD); 70 } 71 else if (GamePad.isDownPressed()) 72 { 73 motor.run(BACKWARD); 74 motor2.run(BACKWARD); 75 motor3.run(BACKWARD); 76 motor4.run(BACKWARD); 77 } 78 79 myservo.write(directionval); 80 81 motor.setSpeed(vitesse); 82 motor2.setSpeed(vitesse); 83 motor3.setSpeed(vitesse); 84 motor4.setSpeed(vitesse); 85 86 delay(10); 87}
4wd
arduino
You need to install two libraries to use it : - Adafruit motor shield library - Dabble
1#include <AFMotor.h> 2#include <Servo.h> 3 4#define CUSTOM_SETTINGS 5#define INCLUDE_GAMEPAD_MODULE 6#include <Dabble.h> 7 8AF_DCMotor motor(1); 9AF_DCMotor motor2(2); 10AF_DCMotor motor3(4); 11AF_DCMotor motor4(3); 12 13Servo myservo; 14 15 int vitesse = 0; 16 int directionval = 90; 17 18 void setup() 19{ 20 Serial.begin(250000); // make sure your Serial Monitor is also set at this baud rate. 21 Dabble.begin(9600,0,1); 22 23 myservo.attach(10); 24 25 motor.run(RELEASE); 26 motor2.run(RELEASE); 27 motor3.run(RELEASE); 28 motor4.run(RELEASE); 29 myservo.write(90); 30} 31 32void loop() 33{ 34 Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile. 35 36 if(GamePad.isLeftPressed()){ 37 if (directionval < 110){ 38 directionval++; 39 } 40 } 41 else if( GamePad.isRightPressed()){ 42 if (directionval > 70){ 43 directionval--; 44 } 45 } 46 else if(GamePad.isCirclePressed()){ 47 directionval = 90; 48 vitesse = 0; 49 motor.run(RELEASE); 50 motor2.run(RELEASE); 51 motor3.run(RELEASE); 52 motor4.run(RELEASE); 53 } 54 else if (GamePad.isCrossPressed()){ 55 if(vitesse < 255){ 56 vitesse += 5; 57 } 58 } 59 else if (GamePad.isSquarePressed() ){ 60 if(vitesse > 0){ 61 vitesse -= 5; 62 } 63 } 64 else if (GamePad.isUpPressed()) 65 { 66 motor.run(FORWARD); 67 motor2.run(FORWARD); 68 motor3.run(FORWARD); 69 motor4.run(FORWARD); 70 } 71 else if (GamePad.isDownPressed()) 72 { 73 motor.run(BACKWARD); 74 motor2.run(BACKWARD); 75 motor3.run(BACKWARD); 76 motor4.run(BACKWARD); 77 } 78 79 myservo.write(directionval); 80 81 motor.setSpeed(vitesse); 82 motor2.setSpeed(vitesse); 83 motor3.setSpeed(vitesse); 84 motor4.setSpeed(vitesse); 85 86 delay(10); 87}
Downloadable files
Bluetooth wiring
Bluetooth wiring

Comments
Only logged in users can leave comments