Jeremy S. Cook
Published

ClearWalker Bluetooth Control

In this project, I'll be outlining how I am able to control my ClearWalker strandbeest-style contraption via Bluetooth.

IntermediateShowcase (no instructions)10 hours3,487
ClearWalker Bluetooth Control

Things used in this project

Hardware components

Arduino Mega 2560 & Genuino Mega 2560
Arduino Mega 2560 & Genuino Mega 2560
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1

Software apps and online services

Arduino Bluetooth Controller
Arduino IDE
Arduino IDE

Story

Read more

Schematics

cci05262017-crop1_NSPLpsWOjU.jpg

Code

Beest-control.ino

Arduino
Motor controls via a PWM H-bridge switch. Some LED matrix commands in this version, but most lighting is not yet added.
#include <Servo.h>
#include <SoftwareSerial.h>
#include <LedControl.h>
#include <binary.h>

SoftwareSerial BT(10, 11); //serial on pins 10/11
                           // connect BT module TX to D10
                           // connect BT module RX to D11

Servo rtmotor; //controls RT H-bridge as servo
Servo ltmotor; //controls LT H-bridge as servo

int rtpos = 90; //stores right servo position (init 90 for off)
int ltpos = 90; //stores left servo position (init 90 for off)

void setup() {
  //"servo" motor setup
  rtmotor.attach(2);
  ltmotor.attach(3);
  //Bluetooth setup
  BT.begin(9600); //sets data rate for SoftwareSerial port
  //eye matrix setup
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);  
  pinMode(13, OUTPUT); //light as needed
}


char a;
void loop() {
  //initial eye setup (eyes small)
  lc.clearDisplay(0);
  lc.setColumn(0,3,B001100);
  lc.setColumn(0,4,B001100);

  //if BT available go into main control loop
  if (BT.available())
  {
    a=(BT.read());
    if (a=='0') //start command to stop motors
    {
      rtmotor.write(90);
      ltmotor.write(90);
      digitalWrite(13, LOW);
    }
    if (a=='1') //forward command
    {
      rtmotor.write(180);
      ltmotor.write(180);
      digitalWrite(13, HIGH);
    }
    if (a=='2') //backward command
    {
      rtmotor.write(0);
      ltmotor.write(0);
    }
    if (a=='3') //right turn command
    {
      rtmotor.write(0); //rt motor goes backward
      ltmotor.write(180); //lt motor goes forward
    }
    if (a=='4') //left turn command
    {
      rtmotor.write(180); //rt motor forward
      ltmotor.write(0); //lt motor goes backward
    }
  }

}

Credits

Jeremy S. Cook

Jeremy S. Cook

39 projects • 310 followers
Engineer, maker of random contraptions, love learning about tech. Write for various publications, including Hackster!

Comments