These are projects and tips that I've recorded for others to understand and recreate. Click on the categories right below to find projects!
Saturday, January 30, 2016
Atmega88p code for a 16x1 LCD Screen
The pictures above uses the code below. The LCD screens are 1 by 16 and are split into 2 parts of 8.
Replace the pink XXXXXXXX, with the desired words, but remember, the screen is split in 2 parts.
//#define F_CPU 4000000UL
#include <avr/delay.h>
#include <avr/io.h>
/*LCD function declarations */
void LCD_send_command(unsigned char cmnd);
void LCD_send_data(unsigned char data);
void LCD_init();
void LCD_goto(unsigned char y, unsigned
char x);
void LCD_print(char *string);
void LCD_blink();
void LCD_scroll(unsigned char direction);
#define LCD_DATA_PORT PORTB
#define LCD_DATA_DDR DDRB
#define LCD_DATA_PIN PINB
#define LCD_CNTRL_PORT PORTC
#define LCD_CNTRL_DDR DDRC
#define LCD_CNTRL_PIN PINC
#define LCD_RS_PIN 0
#define LCD_RW_PIN 1
#define LCD_ENABLE_PIN 2
int main(void)
{
DDRD =0xFF;
PORTD|=1<<0;
PORTD|=1<<1;
PORTD|=1<<2;
PORTD|=1<<3;
PORTD|=1<<4;
unsigned
char i;
LCD_init();
LCD_goto(1,1);
LCD_print("XXXXXXXX");
LCD_goto(2,1);
LCD_print("XXXXXXXX");
}
/* This function sends a command 'cmnd' to
the LCD module*/
void LCD_send_command(unsigned char cmnd)
{
LCD_DATA_PORT
= cmnd;
LCD_CNTRL_PORT
&= ~(1<<LCD_RW_PIN);
LCD_CNTRL_PORT
&= ~(1<<LCD_RS_PIN);
LCD_CNTRL_PORT
|= (1<<LCD_ENABLE_PIN);
_delay_us(2);
LCD_CNTRL_PORT
&= ~(1<<LCD_ENABLE_PIN);
_delay_us(100);
}
/* This function sends the data 'data' to
the LCD module*/
void LCD_send_data(unsigned char data)
{
LCD_DATA_PORT
= data;
LCD_CNTRL_PORT
&= ~(1<<LCD_RW_PIN);
LCD_CNTRL_PORT
|= (1<<LCD_RS_PIN);
LCD_CNTRL_PORT
|= (1<<LCD_ENABLE_PIN);
_delay_us(2);
LCD_CNTRL_PORT
&= ~(1<<LCD_ENABLE_PIN);
_delay_us(100);
}
void LCD_init()
{
LCD_CNTRL_DDR
= 0xFF;
LCD_CNTRL_PORT
= 0x00;
LCD_DATA_DDR
= 0xFF;
LCD_DATA_PORT
= 0x00;
_delay_ms(10);
LCD_send_command(0x38);
LCD_send_command(0x0C);
LCD_send_command(0x01);
_delay_ms(10);
LCD_send_command(0x06);
}
/* This function moves the cursor the line
y column x on the LCD module*/
void LCD_goto(unsigned char y, unsigned
char x)
{
unsigned
char firstAddress[] = {0x80,0xC0,0x94,0xD4};
LCD_send_command(firstAddress[y-1]
+ x-1);
_delay_ms(10);
}
void LCD_print(char *string)
{
unsigned
char i=0;
while(string[i]!=0)
{
LCD_send_data(string[i]);
i++;
}
}
void LCD_blink()
{
LCD_send_command(0x08);
_delay_ms(250);
LCD_send_command(0x0C);
_delay_ms(250);
}
void LCD_scroll(unsigned char direction)
{
if(direction
== 0)
LCD_send_command(0x18);
else
LCD_send_command(0x1C);
_delay_ms(500);
}
How to make a 12V PIR motion light with 5v PIR module, a mosfet and NPN transistor Part 2
In the circuit above, it is just a modification of the part one circuit, replacing the PNP transistors with a N-channel mosfet and a NPN transistor. The circuit can be used with voltages from 8V-20V, using the LM7805, regulating the voltage to 5v for the PIR Module. The output of this circuit is controlled by the N-channel mosfet with controls the negative rail. To vary the time that the mosfet stays on, you would increase the capacitance of C1 and C2 for a longer ON time, but it would take a longer time to turn on( about 3-5 seconds), if you decrease the capacitance of the 2 capacitors, it would decrease the ON time, and the time from trigger to turning on would decrease as well.
The side and bottom picture, shows the circuit in place to act as a hallway motion light.
The side and bottom picture, shows the circuit in place to act as a hallway motion light.
Saturday, January 16, 2016
How to make Pir Motion lights with npn and pnp transistors Part1
The circuit shows a PIR module connected to a npn and pnp transistor and a relay. This configuration allows, lights to be turned on when the PIR module sees an infrared pattern occur (when a person or warm blooded mammal goes in front of the module.With the 2 1000uf capacitors, the module turns on and stays on for about 1 minute. To increase or decrease the length of time, you would reduce the capacitor ratings to decrease time and increase capacitor capacity to increase time.
The diagrams below, show the pinouts of 2n2222 and 2n2907.
Pir Module |
How to make a Bench Power supply using (2) Lm317 Part-2
TIP31 pinouts above. |
The circuit above is another bench power supply, but with 2 modification. The modifications, above is replacing the variable resistor for current limiting to a transistor, so that heat can be dissipated easily that a normal variable resistor. The circuit allows the current to be lowered from 0 to 2 amps, with proper heatsinking. The second modification is the bypass switch where it allows the full current from the power supply to be able to be used, instead of having a limit, because there is a current drop from the transistor. Other than these 2 modifications, everything else is the same as the other schematic.
Saturday, January 2, 2016
How to make a simple Bench Power supply using (2) Lm317 #1
Lm317 pinouts |
The circuit above is a simple 3 amp variable bench power supply. It uses 2 Lm317 where the first lm317 controls the current and the second controls the voltage. This circuit uses a cooling fan to cool the lm317 which are attached to a heatsink, to prevent them from overheating, there is a diode to act as polarity protection and an led (which should have a 1k resistor in series) to indicate when power is on. The input voltage can range to 5-30v and output can range from 1.25v to 28v at 3 amps. To use the circuit, first turn the second potentiometer to adjust the voltage then use the second potentiometer to adjust the needed current.
This is fairly useful when testing, using and building projects or other circuits.