Sunday, June 29, 2014

Forward and Reverse Circuit for a DC Motor

I've been wanting to build a robot that drove around and if it came to an object, it would sense it with a ping sensor and stop and turn the other way. I was in a hurry to build a circuit that would make a motor spin both ways, so it took a few hours to get it to work. I never looked to a schematic of an H-bridge. The hardest part was getting the transistors that controlled the two sets of transistors to work. The transistors do get hot, but I've never had one burn up.


Here is the schematic and the circuit on a breadboard on my robot.









Here is the video.








Wednesday, June 25, 2014

Parallax 2x16 3pin LCD

On my YouTube channel I was asked to send the code to this 3 pin LCD project to a fellow YouTuber. I tried to put the code in the comments, but it did not work so I started this blog to post codes and schematics.
  
On this project I used 2 normally open switches, 3 resisters (2 for pull downs for the buttons and one for the LED), 1 3 pin 2x16 Parallax LCD, and 1 Arduino UNO. The LED is connected to  pin 11. The button for turning the LED on or off is connected to pin 9. TxPin is connected to pin 6, that is what controls the LCD. The button for the LCD back light is connected to pin 4. The only trouble I had with this is I couldn't figure out how to not delay the code for 2 seconds for turning the LCD on then off automatically. So if anyone has figured that out, that would be cool and remember to share the code.
 
// made by birdshotbrad@youtube.com
//for the 3 pin Parallax LCD ONLY
int led = 11;
int button = 9; //button to turn on or off LED
int val = 0;
int oldval = 0;
int state = 0;
int TxPin = 6; //lcd pin
int button2 = 4; //lcd backlight
int val2 = 0;
int oldval2 = 0;
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

void setup()
{
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
  pinMode(TxPin, OUTPUT);
  digitalWrite(TxPin, HIGH);
  pinMode(button2, INPUT);
}

void loop()
{
  mySerial.begin(9600);
  delay(100);
  val = digitalRead(button);
  val2 = digitalRead(button2);
 
  if(val2 == HIGH){
  mySerial.write(17); // backlight on
  delay(2000);
  mySerial.write(18); // backlight off
  }

 
  if((val == HIGH) && (oldval == LOW)){ //code to turn on or off LED and to show status of LED on lcd
    state = 1 - state;
    delay(5);
  }
  oldval = val;
 
  if (state == 1) {
    digitalWrite(led, HIGH);
    mySerial.write(12);// refresh lcd
    mySerial.print("LED ON");
    mySerial.write(18);
  }
  else {
    digitalWrite(led, LOW);
    mySerial.write(12);
    mySerial.print("LED OFF");
    mySerial.write(18);
  }
}

This is me demonstrating the LCD above.