0% found this document useful (0 votes)
11 views3 pages

Ralobo

This document contains code for controlling a robot car via Bluetooth. The code defines functions for moving the car forward, backward, left, right and stopping. It controls two motors and uses PWM to control speed. Commands are received over Bluetooth serial and executed accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Ralobo

This document contains code for controlling a robot car via Bluetooth. The code defines functions for moving the car forward, backward, left, right and stopping. It controls two motors and uses PWM to control speed. Commands are received over Bluetooth serial and executed accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

https://www.youtube.com/watch?

v=dW0LxSWf9S4&ab_channel=MundoInventivo

Link para o programa do RALABÔ

https://docs.google.com/document/d/1_a5v8KCxdhe2RctdkJm7XTkR_z2VSoTgT5693V1-Fkk/
edit

// O PROGRAMA DO RALABÔ COMEÇA AQUI


// Mundo Inventivo www.youtube.com/mundoinventivo
// Gelson Leandro Kaul
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(2, 3);

int IN1 = 7;
int IN2 = 6;
int IN3 = 5;
int IN4 = 4;
int PWML = 9;
int PWMR = 10;
char comando;
void setup() {
//Define os pinos como saida
Serial.begin(9600);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(PWML, OUTPUT);
pinMode(PWMR, OUTPUT);
}

void loop() {

while (Serial.available()) {

comando = Serial.read();
if (comando == 'F') {
frente();
}
else if (comando == 'B') {
tras();
}
else if (comando == 'L') {
esquerda();
}
else if (comando == 'R') {
direita();
}
else {
parado();
}
}
}

void tras() {
//Gira o Motor A e B no sentido horario
analogWrite(PWML, 180);
analogWrite(PWMR, 180);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);

void frente() {
//Gira o Motor A e B no sentido anti-horario
analogWrite(PWML, 180);
analogWrite(PWMR, 180);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void esquerda() {
analogWrite(PWML, 180);
analogWrite(PWMR, 180);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}

void direita() {
analogWrite(PWML, 180);
analogWrite(PWMR, 180);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
void parado() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}
// O PROGRAMA DO RALABÔ TERMINA AQUI

You might also like