Saturday, December 31, 2016

Controlling lights with Bluetooth and Arduino



This simple design allows for a user to control their LED's or lights with the use of a relay. The circuit is pretty simple in which, there are only a couple of components; the Bluetooth module- the HC-06 , the Arduino module like a mega, Uno, nano or mini and extensions like a relay and transistor. The circuit can be used in many scenarios like wireless controlled appliances, room lights, fans and etc. As well these Bluetooth modules are cheap if bought online.
The photo on the left shows the HC-06 module with 4 pin-outs.

The photo below shows the circuit design:

Below is the simple code for Arduino:
For the blue highlight, change the integer value to change the pin-out used for the Arduino
Add multiple pinMode for more pins controlled

For the green highlight, change the character value to change the character eg. (1,2,a,b,c) needed to be received by the BT module to do an operation

For the yellow highlight, you can write more operation that it does if the character is received.

You can copy and write more jobs that the Arduino will do if a character is received.

#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11);
void setup()
{
  pinMode(13, OUTPUT);
//eg.  pinMode(12, OUTPUT);
//eg. pinMode(11, OUTPUT);

  BT.begin(9600);
}
char a;
void loop()
{
  if (BT.available())
  {
    a=(BT.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
    }
 
     if (a=='2')
    {
      digitalWrite(13, LOW);
    }

//Example of more code
//     if (a=='3')
// {
//    digitalWrite(12, LOW);
// }

//     if (a=='4')
//   {
//     digitalWrite(12, LOW);
//   }

  }

}


FOR THE APPLICATION USED TO CONTROL THE BLUETOOTH CIRCUIT
Download applications like "Bluetooth terminal" or "Arduino BlueControl" 
*Search up on google play store

In bluetooth terminal, you type in the value that you assigned for an operation and send.

In Arduino BlueControl, you can have variety of ways to control the module, but you would assign a button or arrow to the value that you assigned for an operation.

Monday, December 26, 2016

LED strip lights gradual fader




 

This LED fader circuit requires a Arduino device and a LED strip tape that is RGB colored. The photo on the side shows the cluttered breadboard holding the Arduino nano, mosfets and the LM7805 regulator. It is recommended to solder the components and solder a socket for the Arduino Nano onto a PCB board to maintain proper electrical connect. Typical application for this light circuit are Christmas Lights (which this was used for) and indoor house light decorations. The LED tape used here is a 5 metre roll of 5050 LED lights which was powered by a 12V 3 Amp power supply. The Arduino code cycles through many colors and the rate of change can be changed by changing the delay value in the code.
  The following picture shows the entire circuit diagram: 

Below is the Arduino Code that I found:

Change the integers of the orange highlighted part to change the pinouts of the Arduino
Change the integers of the yellow highlighted part to change the changes of color pattern
Change the integer of the turquoise highlighted part to change the speed of change

const int redled = 11;
const int greenled = 10;
const int blueled = 9;

void setup() {
  setColourRgb(0,0,0);
}

void loop() {
  unsigned int rgbColour[3];

  rgbColour[0] = 0;
  rgbColour[1] = 0;
  rgbColour[2] = 0;

for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
   
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      delay(20);
    }
  }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
  analogWrite(redled, red);
  analogWrite(greenled, green);
  analogWrite(blueled, blue);

 }

Sunday, May 22, 2016

Using Arduino to measure volume of sounds


Above is the code that i wrote and modified. There are some extra line that aren't used or where placed for other purposes like the lines for the last IF and Else statement.

buzzer
The code above shows how an Arduino can be programmed so that it can measure the varied sounds and sound levels of its surroundings. It this code, it tells about when the level of sound is high a buzzer would sound, also a Led would light up whenever there is a reaction of noise in its surroundings. To read the sound levels, the code contains lines which tell it to send a word or a phrase to a computer through serial connection. These words are set to be transmitted whenever they reach a certain line of level of volume or frequency.  The parts used here from a grove kit for an Arduino Uno or others.

microphone with oamp















The hardware

Saturday, January 30, 2016

How to wire the LCD pinouts for the Atmega88p

Above shows the Pinout of where and what the 1x16 LCD Screen is connected to for the Atmega88p LCD code. The pinouts on the LCD screen show the parts of the LCD and the Legend shows where the pinouts of the LCD are connected to the Atmega88p.

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.




Saturday, January 16, 2016

How to make Pir Motion lights with npn and pnp transistors Part1

 Pir Motion lights
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.
Bench Power supply using (2) Lm317 Part-2 Project
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.