Il 0% ha trovato utile questo documento (0 voti)
0 visualizzazioni11 pagine

Controllino Ai - Code Generator For Arduino, Esp32, Controllino & More

Il documento descrive un progetto per costruire un veicolo autonomo che evita ostacoli utilizzando Arduino. Vengono forniti dettagli sui componenti necessari, come il sensore ultrasonico e il driver del motore, insieme a un codice di esempio per il funzionamento del veicolo. Inoltre, si discute l'aggiunta di funzionalità per monitorare il livello della batteria e notificare l'utente tramite LED e buzzer quando la batteria è scarica.

Caricato da

John Papajohn
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PDF o leggi online su Scribd
Il 0% ha trovato utile questo documento (0 voti)
0 visualizzazioni11 pagine

Controllino Ai - Code Generator For Arduino, Esp32, Controllino & More

Il documento descrive un progetto per costruire un veicolo autonomo che evita ostacoli utilizzando Arduino. Vengono forniti dettagli sui componenti necessari, come il sensore ultrasonico e il driver del motore, insieme a un codice di esempio per il funzionamento del veicolo. Inoltre, si discute l'aggiunta di funzionalità per monitorare il livello della batteria e notificare l'utente tramite LED e buzzer quando la batteria è scarica.

Caricato da

John Papajohn
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PDF o leggi online su Scribd
Sei sulla pagina 1/ 11
2am, 9:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more © ¢ (hitps://www.controllino.ai) CONTROLLINO Al Our Al can write fully working Arduino code in C or MicroPython, answer fo inquiries about Arduino and CONTROLLINO products and services or guide you through setup and configuration processes. Use it as an Arduino Al Code Generator, your personal CONTROLLINO support agent and more! Guest: Building a self-propelled obstacle-avoiding vehicle based on Arduino is an important project for learning robotics and programming microcontrollers. Avoiding obstacles is one from basic functions to robotic systems, allowing vehicles to move autonomously in an objectfree environment. Leds and buzzers for obstacle detection and also when battery level is at 10% state of charge. Materials and Equipment: Arduino UNO. Motor Driver (L298N) for controlling DC motors. HC-SRO4 ultrasonic sensor for obstacle detection. DC motors and wheels for driving the vehicle. Chassis for the vehicle. Batteries to power the system. Connecting cables and breadboard for the connections. LEDs, Buzzer for visual and audible notification when obstacles are detected. eNankena Al That sounds like an awesome project! «Building a seltpropelled obstacle-avoiding vehicle is a great way to dive into robotics and learn about microcontrollers. Let's break down the components and how you can connect everything together. Here’s a quick overview of how to set up your project: 1. Components Overvi + Arduine UNO: The brain of your robot + Motor Driver (L298N): This will control the DC motors based on commands from the Arduino, + HC-SRO4 Ultrasonic Sensor: This will help detect obstacles by measuring distance. + DC Motors and Wheels: These will drive the vehicle, ‘+ Chassis: The structure to hold everything together. hitps:ww-contratna a wm zara, 8:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more ‘* Batteries: To power your system. LEDs and Buzzer: For notifications when obstacles sederecteds \hen the battery is low. ow (hitps://www.controllino.ai) Here's a simple wiring setup: * HC-SRO4: © VCC to Arduino 5V © GND to Arduino GND © Trig to a digital pin (e.g., D2) © Echo fo another digital pin (e.g., D3) + L298N Motor Driver: © Connect the motor outputs to your DC motors. © INI, IN2 to Arduino digital pins (e.g., D4, D5 for one motor) © INS, IN4 to Arduino digital pins (e.g., D6, D7 for the other motor) © ENA and ENB fo Arduino PWM pins (e.g., D9, D10) for speed control © Power the L298N with your battery. * LEDs and Buzzer: © Connect LEDs to digital pins with appropriate resistors. © Connect the buzzer to another digital pin. 3. Sample Code: Here's a basic sketch to get you started. This code will read the distance from the ultrasonic sensor and control the motors accordingly. It also includes functionality for the LEDs and buzzer. hitps:tmww-contratna a am zara, 9:20 my. #include #define TRIG_PIN 2 #define ECHO_PIN 3 #define MOTOR_A1 4 #define MOTOR _A2 5 ##define MOTOR_B1 6 #tdefine MOTOR_B2 7 itdefine LED_PIN 8 fidefine BUZZER_PIN 9 void setup0 ( pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(MOTOR_A1, OUTPUT); pinMode(MOTOR _A2, OUTPUT); pinMode(MOTOR_B1, OUTPUT); pinMode(MOTOR_B2, OUTPUT); pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); Serial.begin(960); void loop() { long duration, distance; // Trigger the ultrasonic sensor digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); duration = pulsein(ECHO_PIN, HIGH); CONTROLLINO Al - Code Generator for Ardulro, ESP32, CONTROLLINO & more © 9 lam) (hitps://www.controllino.ai) distance = (duration * 034 / 2); // Distance in cm Serial.print("Distance: "); Serial.printIn(distance); if (distance < 20) { // If obstacle is detected within 20 cm digitalWrite(LED_PIN, HIGH); // Turn on LED dig stopMotors(); yelse { IWrite(BUZZER_PIN, HIGH); // Turn on Buzzer digitalWrite(LED_PIN, LOW); // Turn off LED digitalWrite(BUZZER_PIN, LOW); // Turn off Buzzer hitps:tmwn-contratna a amt 2art0r28, 8:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more moveForward(); ) © ¢ delay(100); (https://www.controllino.ai) void moveForward() ( digitalWrite(MOTOR_A1, HIGH); digitalWrite(MOTOR_A2, LOW); digitalWrite(MOTOR_81, HIGH); digitalWrite(MOTOR_B2, LOW); void stopMotors() { digitalWrite(MOTOR_A1, LOW); digitalWrite(MOTOR_A2, LOW); digitalWrite(MOTOR_B1, LOW); digitalWrite(MOTOR_B2, LOW); 4, Next Steps: + Assemble all the components based on the wiring diagram * Upload the code to your Arduino UNO. * Test the vehicle to see how it behaves around obstacles! If you have any questions or need help with specific parts of the project, just let me know! Happy building! & — forgot the use of leds and buzzer once battery is drained Al: No problem! Let's add functionality to check the battery level and nofify you with the LEDs and buzzer when the battery is low. You can use an analog pin to read the battery voltage and determine if it's below a certain threshold (like 10%). Updated Code with Battery Monitoring Here's how you can modify the previous code to include battery level monitoring hitps:ww-contratna a an zara, 9:20 my. #include #define TRIG_PIN 2 #define ECHO_PIN 3 #define MOTOR_A1 4 #define MOTOR _A2 5 #define MOTOR_B1 6 #tdefine MOTOR_B2 7 itdefine LED_PIN 8 void setup() ( Serial.begin(960); void loop() { pelse { di hitps:mww-contratna a #tdefine BUZZER PIN 9 #tdefine BATTERY PIN A // Analog pin to read battery voltage const float BATTERY_THRESHOLD = const float ADC_REF_VOLTAGE = 5,; // Reference voltage for ADC const int ADC_MAX_VALUE = 1023; // Maximum value from ADC (10- CONTROLLINO Al - Code Generator for Ardulro, ESP32, CONTROLLINO & more @ go Collermtx) (hitps://www.controllino.ai) 0,; // Set threshold for battery voltage in volts it resolution) pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(MOTOR _A1, OUTPUT); pinMode(MOTOR _A2, OUTPUT); pinMode(MOTOR_B1, OUTPUT); pinMode(MOTOR_B2, OUTPUT); pinMode(LED_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); long duration, distance; // Check battery level float batteryVoltage = readBatteryVoltage(); if (batteryVoltage < BATTERY_THRESHOLD) { digitalWrite(LED_PIN, HIGH); // Turn on LED for low battery digitalWrite(BUZZER_PIN, HIGH); // Turn on Buzzer for low battery stopMotors0; // Stop the vehicle return; // Exit loop to prevent further actions IWrite(LED_PIN, LOW); // Turn off LED digitalWrite(BUZZER_PIN, LOW); // Turn off Buzzer /1 Trigger the ultrasonic sensor digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); sm 2art0r28, 8:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); © 9 digitalWrite(TRIG_PIN, LOW); ' (hitps://www.controllino.ai) duration = pulseln(ECHO_PIN, HIGH); distance = (duration * 034 / 2); // Distance in cm Serial print("Distance: "); Serial.printIn(distance); if (distance < 20) { // If obstacle is detected within 20 cm digitalWrite(LED_PIN, HIGH); // Turn on LED digitalWrite(BUZZER_PIN, HIGH); // Turn on Buzzer stopMotors(); else ¢ digitalWrite(LED_PIN, LOW); // Turn off LED digitalWrite(BUZZER_PIN, LOW); // Turn off Buzzer moveForward\); ) delay(100); float readBatteryVoltage() { int adcValue = analogRead(BATTERY PIN); // Read the analog value from the battery pin float voltage = (adcValue / (float)ADC_MAX_VALUE) * ADC_REF_VOLTAGE * (11.); // Assuming a voltage divider with a ratio of 11:1 return voltage; // Return the battery voltage void moveForward() { digitalWrite(MOTOR_A1, HIGH); digitalWrite(MOTOR_A2, LOW); digitalWrite(MOTOR_B1, HIGH); digitalWrite(MOTOR_B2, LOW); void stopMotors() { digitalWrite(MOTOR_A1, LOW); digitalWrite(MOTOR_A2, LOW); digitalWrite(MOTOR_B1, LOW); digitalWrite(MOTOR_B2, LOW); hitps:tmww-contratna a amt 2200/24, 820 14 CONTROLLINO Al - Code Generator for Arduino, ESP32, CONTROLLINO & more Key Changes: + Battery Moni using an analog pin (A in this case) + Threshold Check: If the battery voltage drops below the specified threshold (10V), the vehicle stops, and the LED and buzzer are activated to notify you, 9: The readBatteryVoltage() © roars the voltage from the baltery (hitps://www.controllino.ai) Note: ‘+ Make sure fo adjust the vollage divider ratio in the readBatteryVoltage() function if you're using a different setup. + You may need to calibrate the battery threshold based on your battery specifications. IF you need further assistance or have any questions, feel free to ask! Happy coding! © Generate Code Lol the Al write Arduino code and download the ino file instantly Get Help Use the Al as a highly powerful knowledge and support agen Learn new things Learn Arduino & CONTROLLINO related things on the fh. Starter nitpsitwww.controlina at m1 2am, 9:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more Perfect for starting out 9 (hitps://www.controllino.ai) Free forever @ Base Model: GPT 40 Mini Good quality code generation, very fast model. Optimized for everyday tasks and moderate complexity © Limited Messages Mes: 3 are limited to 30 per month © Limited Text Length Maximum context length of 4,000 tokens {~-3,000 words) © General Knowledge of Microcontrollers Trained on Arduino & CONTROLLINO devices, limited knowledge of other devices like ESP32 and similar © No Vision Support The Al will only work with text-based input. © No Conversation History Only your current conversation is stored. © C++ Safety Standards Write code based on SEI CERT C++, MISRA and other relevant code standards for maximum safety. © Custom Coding Standards Do you have your own coding guidelines thal the Al should follow? We will implement it for you! Get started (https://www.controllino.ai/#start-here) No credit card or login required! Pro Unlimited Messages & History hitps:twwn-contatna a ant 2am, 9:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more 9 € A . J//www-controlline.ai) per month @ Base Models: Highly skilled and fast for code generation. GPT-4o is the second best model for code generation GPT-4o Mini as a good alternative if you want faster speed. PT-40 i & GPT-4o © Unlimited Messages Send as many messages as you want © Enhanced Text Length Maximum context length of 128.000 tokens (~96.000 words) © Specialized Knowledge of Microcontrollers Trained and specialized on Arduino, CONTROLLINO, ESP32, ESP8266, Raspberry Pi Pico, STM32, Teensy, Adafruit Feather, Nucleo and many more devices © Vision Support You can write text to the Al, as well as upload images and documents, like wiring diagrams, datasheets, and more, making the capabilities and responses of the Al much more powerful ted Conversa’ @ Uni Al your previous conversations are retained n History © C++ Safety Standards Write code based on SEI CERT C++, MISRA and other relevant code standards for maximum safety. © Custom Coding Standards Do you have your own coding guidelines thal the Al should follow? We will implement it for you! Upgrade now (https: //www.controllino.ai/product/controllino-ai-pro/) Cancellable anytime Enterprise Top Al Models & Code Safely Features hitps:twwn-contatna a ant 2am, 9:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more Q € 9. QD oonccncine per month @ Base Models: GPT-4o Mini, GPT-4o & Claude 3.5 Sonnet Work with the highest quality code generation model available. Claude 3.5 Sonnet beats ChatGPT / GPT-4o at code generation © Unlimited Messages Send as many messages as you want © Enhanced Text Length Maximum context length of 128.000 tokens (~96.000 words) © Very Specialized Knowledge of Microcontrollers Trained and specialized on Arduino, CONTROLLINO, ESP32, ESP8266, Raspberry Pi Pico, STM32, Teensy, Adafruit Feather, Nucleo and mary more devices, paired with the highes' quality models for coding like Claude 3.5 Sonne! that has even more knowledge and skills than GPT-4o. © Vision Support You can write tex fo the Al, as well as upload images and documents, lke wiring diagrams, datasheets, and more, making the capabilities and responses of the Al much more powerful © Unlimited Conversation History All your previous conversations are retained © C++ Safety Standards Write code based on SEI CERT C++, MISRA and other relevant code standards for maximum safety. © Custom Coding Standards Do you have your own coding guidelines thal the Al should follow? We will implement it for you Upgrade now (https: //www.controllino.ai/product/controllino-ai-enterprise/) Cancellable anytime Need an industry-ready Arduino? Check out our CONTROLLINO PLCs. hitps:twwn-contatna a sont 2am, 9:20 my. ‘CONTROLLINO Al Code Generator for Arduino, ESP32, CONTROLLINO & more wiww.controllino.ai) © Q (hitps://www.controllino. CONTROLLINO A is offered for free by CONTROLLINO: The first industry-grade PLC with open source software, fully compatible with Arduino. Check out our products (https: //www.controllino.ai/shop/) MICRO hts: //www.conttolline.com/praduct-category/contrllers/micro/) MINI(atips://www.controline.com/producteatagory/contrllors/mini/) MAXI[htps://www.controlline.com//productcategory/controllers/maxi/) MEGA\https://svww contrllino,com//product-categon/controllers/mega/) Accessoriesthiips://www.controlline com//pro sgory/accessories/) Kisthtps: /Auww-controllino. com//productcategory/kits/) Relays ps://wwn.controllino.com //productcategory/relays/) Imprinithips://ww.controllina.i/imprini/) Terms of Servicethtips://www controling ai/ios/} Data Privacy(htips://www controllino.ai/privacy/) hitps:twwn-contatna a wt

Potrebbero piacerti anche