Skip navigation

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).

Today, my mom had to return something at Home Depot.  She sent me inside, saying I could use the refund to get some stuff.  I remembered an instruction at http://kennethfinnegan.blogspot.com/2010/01/switching-120vac-with-5v-digital-logic.html and got most of the parts. I could not find the terminal block, but that can wait.  MY main problem is that I do not have a 5v relay, I have a 12v one.  If I had to feed in 12v, I would also need to keep my wall wart handy, and then I wouldn’t be doing anything but following instructions.  So I decided to make a 12v wall wart part of the project.  I just have to hook up 5v and ground to control it.

I decided to do this because my relay is 12v and I therefore would need to always use the 12v wall wart for it.  I put both in a gang box, added a transistor and a resistor, wired them to the outlets and power cord and was done.  I followed the original instructions, but where they said +5v I put in the 12v, and added wires to connect the wall wart to power.  This has the advantage of only needing to connect 2 wires to the arduino as well as only drawing the power needed to control a transistor.  The disadvantage is that it has to be plugged in to test the relay.  I only got shocked two or three times while making this.  Total cost under $15, I had most of the parts on hand.

this is three main parts: the relay board, the power outlet, and the wall wart.  power cord from an old computer.

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

these are some random electronic sculptures, I made them using leftover/ unusable parts and scrap pcbs.  The first one I made is a person, based around a DIP switch.  I tried to solder it into a pcb with some pullup resistors for use in breadboarding, but it didn’t work.  So I built something with some resistors from a hundred pack, an LED with short leads, and a scrap of pcb:

I made several more of these for friends and family, but do not have photographs of all but one:

last, I made a fighter jet, using a free serial port, 5 LEDs I got for 5 cents each, 2 unmarked TO-220 transistors, a few resistors, a DIP switch, a photocell, a switch, and a few resistors on a custom-cut pcb (took a while).

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.