Skip navigation

Category Archives: Arduino

first of all, i got this idea from http://jethomson.wordpress.com/2010/02/21/diy-usb-to-serial-cable-for-3usd/.

today, I got the last of the parts to build an arduino clone and the serial cable that is used to program it.

The cable includes ground, TX, and RX, which are the minimum needed to control it.  I added another wire so it can use usb power.  It then looked like:

the other end was also simple.  I just soldered the wires to a female header socket and covered it in electrical tape:

the boarduino was also simple, I built the power section and then did the rest: it lights up!

then i built the rest, the blink program was pre-loaded:before i put in the chip

I have blinking lights!

next: my evil coilgun.

Advertisements

I built a board to hold an LCD and the parts to control it.  I started it over a week ago, and finished it today(I forgot about it).  it uses the shiftreglcd library and a 74ls164.  To save one I/O pin, the design included an AND gate made from a diode and resistor.  The board reduces a complicated LCD to data, clock, power, and ground. This will keep me from having to make a whole circuit when I want an LCD in my Arduino projects.

lately, I’ve been working on turning a line following robot into one that is controlled by an arduino.  I took out the main board and line following sensor, as they did not work.  I replaced one of the dual AA battery packs with a 9v to power the arduino, and left the other to power the motors.  I installed a switch between the 9v battery and the 2.1mm jack for the arduino, and hotglued it in.  I have ordered a l293d motor driver on eBay, and this will soon be controlled.  I wil but the l293d in a board, then hotglue that board in, below the arduino’s platform, with a female header breaking out the necessary control.  I also ordered a boarduino, which may be optimul for this project.

i got the temperature sensor i bought from sparkfun a while ago working today.  One site I found recommended a 2.2k resistor, but i found 8.8 worked better for me.  I found this by running the demo sketch in the library(in the arduino playground), and fiddling with a potentiometer.  When I got values roughly consistent with another thermometer, I measured the value of the pot’s resistance between the output and 5v(I did not connect ground, so it was not  acting as a voltage divider.  I then connected 7 resistors in series to match this, so a twisted pot wouldn’t corrupt my measurements. it is accurate(within a degree or two), and i hope to make it better.

after an hour of messing with code, I was able to get a simple demo working with a parallax ping and a servo.  This is for a self navigating robot.  When there is an object within 2 feet of the robot, it will stop.  The servo will then rotate, scanning the PING))) sensor, telling which paths are open for travel.  The robot will then choose the one that is closest to its destination.  I have only been working on getting the servo and PINg to work, and another group of people are working on the GPS.  No one has worked out the motor control for the robot tank yet.  I will post the code if anyone asks.  This was composed without access to the internet.

Today, I followed the guide at http://www.arduino.cc/playground/Code/LCD3wires on using a shift register to conserve pins when using an arduino.  As a standard HD44780 LCD requires four data lines, an enable line, a read/write line, and a register select line, it would use at least 7 of the arduino’s 20 input/output pins, some of which you will be using for other purposes.

The board is simple, with half a dozen of the LCD’s 16 pins going to power and ground, for logic and LED backlight power, as well as contrast, although in some conditions you will need a potentiometer for it(pin 3).  The first time I tried to build this, it didn’t work, probably because I used the wrong IC ( I just got 10 74HC595’s from eBay around the time I ordered the LCD).  I used the example that came with the LCD3wire library rather than the example on the site.  I am planning to migrate this to the 74ls164, for which an easier library exists and which uses one less pin, or the 74hc595, which I have more of, and works the same way.

The program displays a random fruit on the first line and the text “Score: 6/7” on the second.  The code needs to be modified so that lines = 2 for a 2 line display(obviously).

Yesterday, I went to PVIT, an engineering club at my School.  WE were working on an arduino robot, and were trying to wire up 2 h bridges to it.They would take 4 pins(1 pwm) each normally, but as our project also was using a GPS module, limit switches, an ultrasonic sensor, and a servo so far, we decided to save pins.  We were setting it to go in forward and reverse, for forward, the 4 pins on the h-bridge had to be fed 100(PWM) and for reverse 01(PWM)0.  THe pins that would occasionally need pwm would need thier own pins, but the others were as simple as an output and a NOT gate.  Not having any IC, I built a NOT gate out of a 2n2222 transistor and 2 resistors according to a diagram I found on http://www.kpsec.freeuk.com/.  I tested this with LEDs, and have drawn a diagram of it for next week’s meeting.

Today, I soldered together a new shield, this one has a switch, shift register, and 7-segment display so far:

I already had a few shields soldered together.  The first has 5 LEDs, a reset button, and a button:

the next has 2 buttons, 3 LEDs, a switch, anda allows access to the reset button and half the pins:

the next has soldered on perfboard with a dual 7-segment display, only half used:

I also had a protoshield from adafruit with a mini breadboard:

This was going to be a minishield with a shift register and a bargraph, I never got around to finish it:

This one was supposed to be a 3×3 led matrix, something must have shorted:

I was trying to breakout an LCD, it should wotk but it uses an uncommon, older chip so I haven’t tried it:

And last, a bunch of stuff I soldered together.  These include a piece of perfoard with headers and a desoldered transistor, a switch, a dip switch that kept popping out of a breadboard, a piezo buzzer, and a few other things:

most of these things work, after re-soldering.  The transistor was salvaged from a batter batter baseball” toy I found, along with several others.  I used it to control the relay in my earlier post

today, I got a 12volt relay working with my arduino and a 2n3904 transistor.  It is only controlling a bi-color LED. when i send “r” or “b” over serial, the relay switches to light that part of the LED.

Total Parts:  Arduino, 2n3904 NPN transistor, common cathode bi-color LED, 1N4001 diode, 12v DPDT relay(SPDT would work), 100ohm resistor, 1Kohm transistor, assorted wire, breadboard.
here is the code:

int led = 19;
int incomingbyte;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}

void loop() {
if (Serial.available() > 0) {
incomingbyte = Serial.read();
}
if(incomingbyte == 98){
digitalWrite(led, HIGH);
}
if(incomingbyte == 114){
digitalWrite(led, LOW);
}
}

the construction is pretty simple, the hard bit is the need of a 12v wall wart/battery.  Both that and the computer need to be connected, so this might not work for some clones.

  1. put the relay in the center of the board.
  2. connect one of the coil contacts with the Vin pin, 12v.
  3. put the relay in parallel with the coil contacts, cathode towards Vin.
  4. connect the other coil contact to the collector of the 3904(right when facing the flat side).
  5. connect your Arduino pin to the base(middle pin) of the 2n3904 with the 1K resistor, for this ocd I used pin 19 aka analog 5.
  6. connect the emitter(left pin facing flat side)of the transistor to ground.
  7. connect the common pin of the relay to 5v.
  8. connect the anodes of the LEDs to the N/C and N/O pins of the arduino
  9. connect the common cathode to ground through the 100ohm resistor.
  10. connect the board to the 12v wallwart and your computer.

all you have to do now is open the Arduino IDE and upload the code.  Open the serial monitor. send “r” or “b”.  The relay should make a clicking noise and the LED will change color.

for a 5v relay, substitute 5v for 12v on the transistor.  You won’t need a wall wart.