Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: WiFi Motorization - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-05-19 00:25:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Ensure the motors are controlled individually: Set */ /* speed, direction, and movement for each motor */ /* independently using L298NX2 library functions. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
// https://github.com/AndreaLombardo/L298N #include
// https://github.com/SanteriLindfors/WiFiProvisioner /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t IN1_A = 5; const uint8_t IN2_A = 6; const uint8_t IN1_B = 7; const uint8_t IN2_B = 8; /***** DEFINITION OF PWM OUTPUT PINS *****/ const uint8_t EN_A = 3; const uint8_t EN_B = 9; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ L298NX2 motors(EN_A, IN1_A, IN2_A, EN_B, IN1_B, IN2_B); WiFiProvisioner::WiFiProvisioner provisioner; void setup(void) { // put your setup code here, to run once: Serial.begin(9600); while (!Serial) { // do nothing } motors.setSpeed(80); // Initialize WiFiProvisioner object provisioner.resetCredentials(); provisioner.enableSerialDebug(true); provisioner.setInputCheckCallback(inputValidationCallback); provisioner.setFactoryResetCallback(factoryReset); provisioner.setOnProvisionCallback(onProvision); provisioner.INPUT_TEXT = "Enter custom value:"; provisioner.INPUT_PLACEHOLDER = "Custom value"; provisioner.INPUT_LENGTH = "4"; } void loop(void) { // put your main code here, to run repeatedly: motors.forward(); printSomeInfo(); delay(3000); motors.stop(); printSomeInfo(); delay(3000); motors.setSpeedA(255); motors.setSpeedB(90); motors.backwardA(); motors.backwardB(); printSomeInfo(); delay(3000); motors.stop(); printSomeInfo(); motors.setSpeedA(90); motors.setSpeedB(255); delay(3000); } void printSomeInfo() { Serial.print("Motor A is moving = "); Serial.print(motors.isMovingA() ? "YES" : "NO"); Serial.print(" at speed = "); Serial.println(motors.getSpeedA()); Serial.print("Motor B is moving = "); Serial.print(motors.isMovingB() ? "YES" : "NO"); Serial.print(" at speed = "); Serial.println(motors.getSpeedB()); } bool inputValidationCallback(const String& input) { // Check if the input is valid return input == "1234"; } void factoryReset() { Serial.println("Factory reset triggered."); provisioner.setShowInputField(true); } void onProvision() { // Conditionally show the input field bool example = false; provisioner.setShowInputField(example); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)