tip120 – 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 http://www.kevingulling.com/2016/12/1409/ Fri, 23 Dec 2016 20:21:39 +0000 http://www.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 8 – Simple Motor Controller http://www.kevingulling.com/2016/12/12-days-of-arduino/ Tue, 20 Dec 2016 21:24:19 +0000 http://www.kevingulling.com/?p=1356 Day 8 of 12 Days of Arduino! Today I’m starting a new project, utilizing a 6v geared motor I found on Ebay. It does 30 RPM’s after the reduction, so it should have plenty of torque for most small-scale projects! This particular motor does not have reversible polarity, so it only spins in one direction, […]

The post 12 Days of Arduino Day 8 – Simple Motor Controller appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
day8

Day 8 of 12 Days of Arduino! Today I’m starting a new project, utilizing a 6v geared motor I found on Ebay. It does 30 RPM’s after the reduction, so it should have plenty of torque for most small-scale projects! This particular motor does not have reversible polarity, so it only spins in one direction, but for this simple project that will due perfectly! My goal here was to create the simplest motor controller possible and my original goal was to try and find a motor that I could run directly off the Arduino Uno io pins, which is a recommended 40mA maximum load. After testing the current on the motor I purchased I found that I was drawing 70mA, which was low enough not to fry anything, but probably not going to hold up over time. But that’s fine because a Tip120 is great in this scenario!

6v motor

6v Geared Motor

Project requires
–Arduino Uno
-Jumper wires
Tip120 Transistor



Using the analogWrite() method we can give the motor a value ranging from 1-255.

sketch8

Sketch – Simple Motor

int motor = 3;

void setup () {
pinMode (motor, OUTPUT);
}
void loop () {
analogWrite (motor, 255);
}

Tomorrow we will add a component to our circuit to control our motors output values. Edit: Changed my mind, instead I build the structure and coolant system for our new project, we will wait another day for the controls.

Check out ICStation for a good deal Arduino Uno R3’s and a huge selection of motors:


The post 12 Days of Arduino Day 8 – Simple Motor Controller appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
1356
12 Days of Arduino – Day 4 – Tremolo FX With Shift Register http://www.kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/ http://www.kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/#comments Fri, 16 Dec 2016 19:31:58 +0000 http://www.kevingulling.com/?p=1284 Welcome back to day 4 of 12 days of Arduino! I’m glad you’ve been following this far, things are about to get exciting! Today I take the keyboard and using a SN74HC595 Texas Instruments Shift Register I create a tremolo effect Project requires –Arduino Uno –Active buzzer –3x button touch switch -220 ohm resistor -3x […]

The post 12 Days of Arduino – Day 4 – Tremolo FX With Shift Register appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
shift register tremolo

Welcome back to day 4 of 12 days of Arduino! I’m glad you’ve been following this far, things are about to get exciting! Today I take the keyboard and using a SN74HC595 Texas Instruments Shift Register I create a tremolo effect



Project requires
–Arduino Uno
–Active buzzer
–3x button touch switch
-220 ohm resistor
-3x 10k ohm resistor
-220 ohm resistor
-Jumper wires
-Tip120
-SN74HC595

SN74HC595 Shift Register datasheet.
Tip 120 datasheet from adafruit.

arduino keyboard with tremelo

Keyboard with Tremolo Sketch


//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

int number = 1;
int speakerPin = 6;

//Buttons
int button1Pin = 2;
int button2Pin = 3;
int button3Pin = 4;

void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(speakerPin, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);

}

void loop() {
if(digitalRead(button1Pin) == HIGH){
tone(speakerPin, 1000);
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else if(digitalRead(button2Pin) == HIGH){
tone(speakerPin, 2000);
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else if(digitalRead(button3Pin) == HIGH){
tone(speakerPin, 3000);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
number++;
}
else{
number = 0;
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, number);
digitalWrite(latchPin, HIGH);
delay(10);
}

}

One thing to note here is that MSBFIRST means “most significant bit first” and LSBFIRST means “least significant bit first”. We want to use MSBFIRST to accomplish this effect. Basically what’s happening here is we increment 0 by 1 each time the loop is ran and as a result we have an alternating effect on pin 1 of the shift register. A cleaner way to run this would be to increment by 1 and then subtract by 1, but really this is all pointless in the first place, it’s definitely a “Rube Goldberg” way of going about this since you could simply program it with code, but there are opportunities here to utilize 7 more pins, so maybe tomorrow I can make this into something “practical” (I use this term loosely!) and utilize more of the 8 bits of memory we can store here! The possibilities are endless, exciting!

Here’s a tutorial for ShiftOut I highly recommend if you are getting started with shift registers!

Please check out the sponsor of this series:


The post 12 Days of Arduino – Day 4 – Tremolo FX With Shift Register appeared first on Kevin Gulling - Game Development, VR, and more.

]]>
http://www.kevingulling.com/2016/12/12-days-of-arduino-day-4-tremolo-fx-with-shift-register/feed/ 1 1284