De echte Halfzware uit Friesland!
Weerstation

Arduino Bluetooth Tank


 

 

Tank XL

Deze “Bluetooth Tank” is gebouwd naar een idee en ontwerp van Bart Venneker.
Meer leuke projecten en tutorials vind je op zijn website http://www.bartvenneker.nl

Zie hier zijn tutorial over het bouwen van deze tank:

 

De Arduino programmacode:

//
// Bart Venneker 2016
// Bluetooth RC Car
// see http://www.bartvenneker.nl/Arduino/index.php?art=0020 for details
// released into the public domain
//
#include <SoftwareSerial.h>
#define L298N_IN1 7
#define L298N_IN2 6
#define L298N_IN3 5
#define L298N_IN4 4
#define horn 8
#define lightFront 9
#define lightRear 10
#define blinkerRight 11
#define blinkerLeft 12
// Use softserial so we can use the hardware serial for debugging if needed
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
 pinMode(blinkerLeft,OUTPUT);
 pinMode(blinkerRight,OUTPUT);
 pinMode(lightFront,OUTPUT);
 pinMode(lightRear,OUTPUT);
 pinMode(horn,OUTPUT);
 pinMode(L298N_IN1,OUTPUT);
 pinMode(L298N_IN2,OUTPUT);
 pinMode(L298N_IN3,OUTPUT);
 pinMode(L298N_IN4,OUTPUT);
mySerial.begin(9600);
 tone(horn,1000);delay(60);
 tone(horn,800);delay(80);
 noTone(horn);
 }
// Global variables
int dta=0;
int freq;
unsigned long blinkTimer = millis();
unsigned long sireneTimer = millis();
boolean blinker = true;
boolean alarmLights = false;
boolean blinkLeft;
boolean blinkRight;
boolean sirene=false;
void loop() {
 
 // read all data from the serial buffer
 while(mySerial.available() > 0){ 
 int a = mySerial.read() ; 
 if ( a > 13 ) dta = a; // ignore the carriage return character
 delay(2); // wait for more data
 }
 
 switch (dta) {
 case 'S': 
 driveTracks(0,0,0,0); setBlinker(0,0); break; // STOP the car
 case 'F':
 driveTracks(0,1,0,1); setBlinker(0,0); break; // Forward
 case 'B':
 driveTracks(1,0,1,0); setBlinker(0,0); break; // Reverse
 case 'L':
 driveTracks(1,0,0,1); setBlinker(0,1); break; // Left
 case 'R': 
 driveTracks(0,1,1,0); setBlinker(1,0); break; // Right
 case 'G':
 driveTracks(0,0,0,1); setBlinker(0,1); break; // Forward and Left
 case 'I':
 driveTracks(0,1,0,0); setBlinker(1,0); break; // Forward and Right
 case 'H': 
 driveTracks(0,0,1,0); setBlinker(0,1); break; // Backward and Left
 case 'J': 
 driveTracks(1,0,0,0); setBlinker(1,0); break; // Backward and Right
 case 'V': 
 sirene=true; break; // Sirene on
 case 'v':
 sirene=false; break; // Sirene off
 case 'W':
 digitalWrite(lightFront,1); break; // Head lights on
 case 'w':
 digitalWrite(lightFront,0); break; // Head lights off
 case 'U':
 digitalWrite(lightRear,1); break; // Rear lights on
 case 'u':
 digitalWrite(lightRear,0); break; // Rear lights off
 case 'X':
 alarmLights = true; break; // Warning lights on
 case 'x':
 alarmLights = false; break; // Warning lights off 
 }
 
 // This is to control the blinking speed, and drive the blinker lights
 if (millis()-blinkTimer > 250) {
 blinkTimer = millis(); 
 blinker = !blinker; 
 if (blinkLeft | alarmLights) digitalWrite(blinkerLeft,blinker);
 else digitalWrite( blinkerLeft,LOW);
 if (blinkRight | alarmLights) digitalWrite( blinkerRight,blinker);
 else digitalWrite( blinkerRight,LOW);
 }
// This is to control the sirene 
 if (millis()- sireneTimer > 400) {
 sireneTimer=millis();
 if (freq==700) freq=1000;
 else {freq=700; noTone(horn);}
 if (sirene) tone(horn,freq);
 }
}
void driveTracks(bool IN1,bool IN2,bool IN3,bool IN4) {
 digitalWrite(L298N_IN1,IN1);
 digitalWrite(L298N_IN2,IN2);
 digitalWrite(L298N_IN3,IN3);
 digitalWrite(L298N_IN4,IN4); 
}
void setBlinker(bool Right,bool Left){
 blinkLeft = Left;
 blinkRight = Right;
}

Hieronder de Android App voor de besturing…

bluetooth_rc_controller

Zie hier de eerste stapjes van mijn prototype:

En hier de HUD die ik  heb gemaakt voor het filmpje…

Nu de verlichting nog even…

Verlichting_BtTank

 

Tankverlichting