//Starter Code for Emgreat Robot
// Assign Pins for Left Motor
int motorleftPin1 = 8; // IN1 on L298N
int motorleftPin2 = 9; // IN2 on L298N
int enableleftPin = 10; // EN1 on L298N
//Assign pins for right motor
int motorrightPin1 = 12; // IN3 on L298N
int motorrightPin2 = 13; // IN4 on L298N
int enablerightPin = 11; // EN2 on L298N
void setup() { // set the pins you're using as outputs:
pinMode(motorleftPin1, OUTPUT);
pinMode(motorleftPin2, OUTPUT);
pinMode(enableleftPin, OUTPUT);
pinMode(motorrightPin1, OUTPUT);
pinMode(motorrightPin2, OUTPUT);
pinMode(enablerightPin, OUTPUT);
// set enablePins high so that motor can turn on; this can also be used as a speed control using the analogWrite command
analogWrite(enableleftPin, 150); // 150 is a medium speed
analogWrite(enablerightPin, 150);
}
void loop() { //main loop
forward();
delay(1000);
backward();
delay(1000);
turn();
delay(2000);
}
void forward() { //user defined going forwards function
digitalWrite(motorleftPin1, LOW);
digitalWrite(motorleftPin2, HIGH);
digitalWrite(motorrightPin1, LOW);
digitalWrite(motorrightPin2, HIGH;
}
void backward() { //user defined going backwards function
digitalWrite(motorleftPin1, HIGH);
digitalWrite(motorleftPin2, LOW);
digitalWrite(motorrightPin1, HIGH);
digitalWrite(motorrightPin2, LOW);
}
void turn() { //user defined turn function
digitalWrite(motorleftPin1, LOW);
digitalWrite(motorleftPin2, HIGH;
digitalWrite(motorrightPin1, HIGH);
digitalWrite(motorrightPin2, LOW);
}
How to Build a Bluetooth Remote Control with Arduino Uno and HM-10 or HC-05 Module
https://srituhobby.com/how-to-build-a-bluetooth-control-car-with-arduino-nano-and-hc-05-module/
Dabble - Bluetooth Controller 4+
https://apps.apple.com/us/app/dabble-bluetooth-controller/id1472734455
Dabble is a versatile project interaction & Bluetooth controller app for Arduino, ESP32 & evive that replaces a wide variety of electronic components and exploits the inbuilt features and sensors of your Smartphone like the GPS, mic & accelerometer thus transforming into a virtual treasury of infinite shields & more. It lets you control & communicate with hardware via Bluetooth. It also provides you with dedicated projects compatible with Scratch & Arduino to help you learn by doing.
What Dabble has in store:
Currently Available Modules:
• LED Brightness Control: Control brightness of LEDs and digital/analog pins.
• Terminal: Send and receive textual and voice commands over Bluetooth.
• Gamepad: Control devices/robot in analog (Joystick), digital, and accelerometer mode.
• Pin State Monitor: Remotely monitor the live status of devices and debug them.
• Phone Sensor: Access different sensors of your Smartphone such as the accelerometer, gyroscope, proximity sensor, magnetometer, light meter, sound meter, GPS, temperature sensor, and barometer to make projects and conduct experiments.
Coming Soon:
• Motor Control (Coming Soon): Control actuators such as the DC motor and servo motor.
• Inputs (Coming Soon): Provide analog and digital inputs via buttons, knobs, and switches.
• Camera (Coming Soon): Use the camera of your Smartphone for taking photos, record videos, colour picking, and face recognition (coming soon).
• IoT (Coming Soon): Log data, publish it on cloud, and access data from API.
• Oscilloscope (Coming Soon): Visualize and analyse the input and output signals given to the device using the oscilloscope module.
• Music (Coming Soon): Receive commands from the device and play tones, songs, or other recorded audio files on your Smartphone.
• Projects (Coming Soon): Make dedicated projects to experience different concepts of the real world first-hand like home automation, line-follower, and robotic arm.
Boards Compatible with Dabble:
• evive
• Arduino Uno
• Arduino Mega
• Arduino Nano
• ESP32
Bluetooth Modules Compatible with Dabble:
• HM-10 BT 4.0 BLE (or AT-09)
HC-05
Want to know more about Dabble? Visit: https://thestempedia.com/product/dabble/
Module Documentation: https://thestempedia.com/docs/dabble/
Getting Started with Dabble: https://thestempedia.com/docs/dabble/getting-started-with-dabble/
Projects that you can make: https://thestempedia.com/product/dabble-app/
Sample Code:
/*
Gamepad module provides three different mode namely Digital, JoyStick and Accerleometer.
You can reduce the size of library compiled by enabling only those modules that you want to
use. For this first define CUSTOM_SETTINGS followed by defining INCLUDE_modulename.
Explore more on: https://thestempedia.com/docs/dabble/game-pad-module/
Wiring:
GND of HM10 to GND of Arduino
VCC of HM10 to 5V of Arduino
TX of HM10 to Digital Pin 2 of Arduino
RX of HM10 to Digital Pin 3 of Arduino
*/
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // make sure your Serial Monitor is also set at this baud rate.
Dabble.begin(9600); //Enter baudrate of your bluetooth.Connect bluetooth on Bluetooth port present on evive.
// sample LEDs for demo
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
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.
//Serial.print("KeyPressed: ");
if (GamePad.isUpPressed()) {
Serial.println("UP");
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
if (GamePad.isDownPressed()) {
Serial.println("DOWN");
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(8, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
if (GamePad.isLeftPressed()) {
Serial.println("Left");
digitalWrite(9, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(9, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
if (GamePad.isRightPressed()) {
Serial.println("Right");
digitalWrite(10, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(10, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
delay(500);
}
Science Buddies:
Arduino Self-Driving Car
https://www.youtube.com/playlist?list=PLlBVuTSjOrckzVWHWOYAkyKoQZhmoqH1S