martes, 18 de junio de 2019
Código del proyecto
#include <SoftwareSerial.h>
#include "ABLocks_TimerFreeTone.h"
double dato;
SoftwareSerial bt_serial(3,2);
void adelante() {
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
analogWrite(11,255);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
analogWrite(11,255);
digitalWrite(A5, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
void izquierda() {
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
analogWrite(11,255);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
analogWrite(11,255);
digitalWrite(A5, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
void atras() {
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
analogWrite(11,255);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
analogWrite(11,255);
digitalWrite(A5, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
}
void derecha() {
digitalWrite(6,LOW);
digitalWrite(7,LOW);
analogWrite(11,255);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
analogWrite(11,255);
digitalWrite(A5, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void claxon() {
TimerFreeTone(8,100,750);
TimerFreeTone(8,500,1200);
TimerFreeTone(8,100,400);
delay(100);
}
void parar() {
digitalWrite(6,LOW);
digitalWrite(7,LOW);
analogWrite(11,255);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
analogWrite(11,255);
digitalWrite(A5, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void setup()
{
bt_serial.begin(9600);
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(A5, OUTPUT);
dato = 5;
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
void loop()
{
if ((bt_serial.available()>0)) {
dato = bt_serial.read();
Serial.println(dato);
if ((dato == 1)) {
adelante();
}
if ((dato == 2)) {
atras();
}
if ((dato == 3)) {
izquierda();
}
if ((dato == 4)) {
derecha();
}
if ((dato == 5)) {
parar();
}
if ((dato == 6)) {
claxon();
}
delay(100);
}
}
Suscribirse a:
Entradas (Atom)
Calc - Gráficas
Descargar archivo aquí .
-
Tabuladores by on Scribd Descarga el archivos desde aquí
-
Formulas by on Scribd Descarga el archivo desde aquí
-
Código hecho en ArduinoBlocks Boceto de coche hecho en Tinkercad