Danke soweit funktioniert es super
ToastCrafterHD
Druckbare Version
Danke soweit funktioniert es super
ToastCrafterHD
Da mein erstes Shield meine starken Motoren nicht auf Dauer aushält, habe ich mir jetzt das Pololu Dual VNH5019 Motor Driver Shield for Arduino
gekauft (https://www.pololu.com/product/2507). Diese funktioniert super und schaft die Motore mit links aber ich kann es nur über USB steuern und nicht über Bluetooth. Wo liegt mein Fehler?
Mein Arduino Code:
und mein Processing Code:Code:#include <DualVNH5019MotorShield.h>
#include <SoftwareSerial.h>
char val;
int i = 100;
int o = -100;
int p = 0;
int bluetoothTx = 2;
int bluetoothRx = 4;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
DualVNH5019MotorShield md;
void setup()
{
md.init();
Serial.begin(115200);
bluetooth.begin(115200);
}
void loop()
{
{
if (bluetooth.available())
{
val = bluetooth.read();
Serial.print(val);
}
else if (Serial.available())
{
val = Serial.read();
bluetooth.print(val);
}
}
// anfang motor steuerung
if (val == 'W') {
md.setM1Speed(i);
md.setM2Speed(i);
}
if (val == '0') {
md.setM1Speed(p);
md.setM2Speed(p);
}
if (val == 'S') {
md.setM1Speed(o);
md.setM2Speed(o);
}
if (val == 'A') {
md.setM1Speed(i);
md.setM2Speed(o);
}
if (val == 'D') {
md.setM1Speed(o);
md.setM2Speed(i);
}
}
Danke schon malCode:import processing.serial.*;
Serial port;
int val;
void setup()
{
size(200, 200);
port = new Serial(this, "COM7", 115200);
}
void draw() {
if (keyPressed) {
if(key == CODED){
if (keyCode == UP) {
port.write('W');
}
if (keyCode == DOWN) {
port.write('S');
}
if (keyCode == RIGHT) {
port.write('D');
}
if (keyCode == LEFT) {
port.write('A');
}
}
if (key == '0') {
port.write('0');
}
}
}
ToastCrafterHD
Das Dual VNH5019 Motor Driver Shield verwendet Pin 2 und 4. Das überschneidet sich mit den Bluetooth Pins. Pin 3 und 5 wären noch frei.