HomeMadeGarbage
Published

Blynk-controlled Stag Beetle

I remodeled a stag beetle toy to be controllable with Blynk. I used Adafruit Feather 32u4 Bluefruit LE as the microcontroller.

IntermediateFull instructions provided4 hours356
Blynk-controlled Stag Beetle

Things used in this project

Hardware components

Stag beetle toy
×1
Adafruit Feather 32u4 Bluefruit LE
×1
Motor Driver DRV8835
×1
Li-Ion Battery 100mAh
Li-Ion Battery 100mAh
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

block diagram

Code

stag01e.ino

Arduino
#define BLYNK_USE_DIRECT_CONNECT

#define BLYNK_PRINT Serial

#include <BlynkSimpleSerialBLE.h>
#include <Adafruit_BLE.h>
#include <Adafruit_BluefruitLE_SPI.h>
#include <SPI.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// SHARED SPI SETTINGS (see adafruit webpages for details)
#define BLUEFRUIT_SPI_CS               8
#define BLUEFRUIT_SPI_IRQ              7
#define BLUEFRUIT_SPI_RST              4    // Optional but recommended, set to -1 if unused
#define BLUEFRUIT_VERBOSE_MODE         true

// Create ble instance, see pinouts above
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);

void setup() {
  Serial.begin(9600);

  pinMode(6, OUTPUT); 
  pinMode(11, OUTPUT); 
  pinMode(12, OUTPUT); 
  pinMode(13, OUTPUT); 

  ble.begin(BLUEFRUIT_VERBOSE_MODE);
  ble.factoryReset(); // Optional
  ble.setMode(BLUEFRUIT_MODE_DATA);

  Blynk.begin(auth, ble);
}

//Button Wedget V0
BLYNK_WRITE(V0) {
  if(param.asInt()){
    //motor2 Reverse rotation
    digitalWrite(6, HIGH); 
    digitalWrite(11, LOW); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH);
  }else{
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH);    
  }
}

//Button Wedget V1
BLYNK_WRITE(V1) {
  if(param.asInt()){
    //motor1 Forward rotation
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, LOW); 
    digitalWrite(13, HIGH); 
  }else{
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH);    
  }
}

//Button Wedget V2
BLYNK_WRITE(V2) {
  if(param.asInt()){
    //motor2 Forward rotation
    digitalWrite(6, LOW); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH); 
  }else{
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH);    
  }
}

//Button Wedget V3
BLYNK_WRITE(V3) {
  if(param.asInt()){
    //motor1 Reverse rotation
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, LOW); 
  }else{
    digitalWrite(6, HIGH); 
    digitalWrite(11, HIGH); 
    digitalWrite(12, HIGH); 
    digitalWrite(13, HIGH);    
  }
}

void loop() {
  Blynk.run();
}

Credits

HomeMadeGarbage

HomeMadeGarbage

40 projects • 152 followers
We are family. hobby is D.I.Y!!

Comments

Add projectSign up / Login