bluetooth – Kevin Gulling http://www.kevingulling.com Game Development, VR, and more Mon, 06 Nov 2017 23:07:25 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.13 81085834 12 Days of Arduino Day 11 – Robot Drive and Controls https://kevingulling.com/2016/12/1409/ Fri, 23 Dec 2016 20:21:39 +0000 https://kevingulling.com/?p=1409 Welcome back to Day 11 of 12 Days of Arduino! Today I backtrack a bit and tie up some “loose ends” with the design. The HC-06 that I am using states that it needs 3.3v on the rx, not 5v as I had it set up yesterday. We’ll want to comply with this to avoid […]

The post 12 Days of Arduino Day 11 – Robot Drive and Controls appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
arduino header

Welcome back to Day 11 of 12 Days of Arduino! Today I backtrack a bit and tie up some “loose ends” with the design.
The HC-06 that I am using states that it needs 3.3v on the rx, not 5v as I had it set up yesterday. We’ll want to comply with this to avoid damaging any components. A simple way to go about this is to create a voltage divider using a couple resistors. I use this handy tool that does all the math for you to figure out what resistance resistors are necessary to get our voltage down to 3.3v: Voltage Divider Calculator. I ended up going with a 1k and a 2k resistor to obtain close to 3.3v.

spambot

Pro Tip: You won’t find this in most tutorials or datasheets, the heatsink tab of the TIP120 is directly connected to the Collector.

Because of the heat sink I had connected to both the Tip120’s, when the circuit would close it would also close the circuit to the transistor that was also connected to the heatsink. So unfortunately I had to remove the cool looking heat sink which honestly was probably complete overkill in the first place, more aesthetic than functional, so it’s probably for the best! That being said.

Parts:
-Arduino Uno R3
-Motor
-Fan
-Jumper Wires
-Breadboard
-Spam Can
-2x TIP120 transistors
-HC-05 or HC-06
3d printed core
-1k resistor
-2k resistor



Bluetooth Robot Controller Sketch


Creative Commons License
All code on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

#include

#define rxPin 0
#define txPin 1

int motor = 3;
int fan = 5;
int incomingByte[2];
boolean motorBool = false;
boolean fanBool = false;

SoftwareSerial bluetooth(rxPin, txPin);

void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode (motor, OUTPUT);
pinMode (fan, OUTPUT);
bluetooth.begin(9600);

analogWrite (motor, 0);
analogWrite (fan, 0);
}

void loop() {
if(bluetooth.available()>0){
while(bluetooth.peek() == 'A'){
//bluetooth.println(bluetooth.peek());
bluetooth.read();
incomingByte[0] = bluetooth.parseInt();
bluetooth.println(incomingByte[0], DEC);
if(incomingByte[0] == 1){
motorBool = true;
bluetooth.print("motor:");
bluetooth.println(motorBool, DEC);
}
else if(incomingByte[0] == 0){
motorBool = false;

}
else if(incomingByte[0] == 2){
fanBool = true;
bluetooth.print("fan:");
bluetooth.println(fanBool, DEC);
}
else if(incomingByte[0] == 3){
fanBool = false;

}
}

while(bluetooth.available()>0){
bluetooth.read();
}
}

if(motorBool == true){
analogWrite (motor, 255);
bluetooth.print("motor:");
bluetooth.println(motorBool, DEC);
}
else{
analogWrite (motor, 0);
bluetooth.print("motor:");
bluetooth.println(motorBool, DEC);
}
if(fanBool == true){
analogWrite (fan, 255);
bluetooth.print("fan:");
bluetooth.println(fanBool, DEC);
}
else{
analogWrite (fan, 0);
bluetooth.print("fan:");
bluetooth.println(fanBool, DEC);
}
delay(1000);
}

I didn’t have time today to get as much done as I would like, so tomorrow will be a big day! That or I may have to extend it to day 13… Tomorrow I’ll put everything together and we will take Spambot for a stroll!

Support future projects by shopping at ICStation:


Day 12 →

The post 12 Days of Arduino Day 11 – Robot Drive and Controls appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
1409
12 Days of Arduino Day 10 – Robot Bluetooth Connection https://kevingulling.com/2016/12/12-days-of-arduino-day-10-robot-bluetooth-connection/ Thu, 22 Dec 2016 19:46:57 +0000 https://kevingulling.com/?p=1387 Welcome back to 12 Days of Arduino Day 10. Today we finish the core and connect to a remote computer via bluetooth. Everything has been pretty simple up until this point, so if you are a beginner you might want to watch some tutorials on YouTube and read up on the HC-05 and HC-06 before-hand. […]

The post 12 Days of Arduino Day 10 – Robot Bluetooth Connection appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
12 days of arduino day 10

Welcome back to 12 Days of Arduino Day 10. Today we finish the core and connect to a remote computer via bluetooth. Everything has been pretty simple up until this point, so if you are a beginner you might want to watch some tutorials on YouTube and read up on the HC-05 and HC-06 before-hand.



Parts:
-Arduino Uno R3
-Motor
-Fan
-Jumper Wires
-Breadboard
-Spam Can
-2x TIP120 transistors
-HC-05 or HC-06

Bluetooth Sketch

Bluetooth Sketch

#include <SoftwareSerial.h>

#define rxPin 0
#define txPin 1

int motor = 3;
int fan = 5;
int incomingByte = 0;

SoftwareSerial bluetooth(rxPin, txPin);

void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode (motor, OUTPUT);
pinMode (fan, OUTPUT);
bluetooth.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
if(bluetooth.available()>0){
bluetooth.print("I received: ");
bluetooth.println(incomingByte, DEC);
}
analogWrite (motor, 255);
digitalWrite (fan, HIGH);
delay(1000);
}

Pro Tip: If you have issues uploading your sketch, unplug the Bluetooth module from the rx/tx pins.

Support future projects by visiting our affiliate ICStation for electronics components:


The post 12 Days of Arduino Day 10 – Robot Bluetooth Connection appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
1387