Quantcast
Channel: LED Projects - PIC Microcontroller
Viewing all 387 articles
Browse latest View live

RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller

$
0
0

RGB REMOTE (pinguino+web+linksys)

This project has several uses, it is basically a way to control an RGB LED group (tricolor with common ground) via a web page to select which color we want to show.

RGB REMOTE
It may be a way to harmonize a room, change the color of a swimming pool or just fooling aroun

Step 1

RGB REMOTE webserver and serial connection

RGB REMOTE webserver and serial connection

In my case the web server is in Linksys router which I have “hacked / tunner” and installed a version of Linux opensource … in this case OpenWRT 9.02, with this special version for this type of equipment, It can be more flexible than the original software. Installing LUA and one webserver and I have all that I will need.

As to the little memory space of this team, to host my website, I have included a change and I have installed a 1GB SD card as hard drive so you can play and install things without fear to occupy the 5Mb which has by default. I’ve also created two output interfaces for internal serial ports by default has LINKSYS and that, in principle are control consoles, modifying a bit its used to connect any computer with RS232 communication.

Step 2

RGB REMOTE pinguino

I use a hardware interface with the 18F2550 microcontroller PINGUINO PIC Firmware v2, 12. This has a basic programming, which attempts to transfer via serial communication from the web server and has scripts that send orders and data via serial port. For example by sending the character “R” means to tell the microcontroller that the LEDs turn RED ONLY. And so with all the colors and combinations.

link original http://www.hackinglab.org/pinguino/index_pinguino.html
link Madrid http://pinguino.walii.es

The program basically tells the microcontroller that the serial port and listen when you get status R eg send a pulse to continuous 5volts particular output for the red LEDs. And finally sent to the serial port the color name that is kindled.
The code is as follows. USE PINGUINO GUI to programate it.
// Prueba de Puerto serie comandando RGB

// walii.es 2010

//aquí agregamos las posibles variables.

int i; //para nuestro contador de puertos

int key; //para la tecla que escucha por el Puerto serie.

void setup()

{

//Aquí configuramos los puertos de salida para que inicien

//en estado de SALIDA y APAGADOs.

for (i=1;i<4;i++){

pinMode(i,OUTPUT);

digitalWrite(i,LOW);

}

//Aquí configuramos el Puerto serie, para que escuche peticiones a 9600bps,

//suficiente para este proyecto.

Serial.begin(9600);

}

//Y por acá podemos ver la configuración de comandos a escuchar en el Puerto

//serie y hacer lo necesario para iniciar los leds que correspondan a la acción

void loop()

{

if Serial.available()

{

key=Serial.read(); //escucha el Puerto serie…

if (key==’r’) digitalWrite(1,1),digitalWrite(2,0),digitalWrite(3,0),Serial.print(“rojo”);

if (key==’v’) digitalWrite(1,0),digitalWrite(2,1),digitalWrite(3,0),Serial.print(“verde”);

if (key==’a’) digitalWrite(1,0),digitalWrite(2,0),digitalWrite(3,1),Serial.print(“azul”);

if (key==’m’) digitalWrite(1,1),digitalWrite(2,1),digitalWrite(3,0),Serial.print(“marron”);

if (key==’b’) digitalWrite(1,1),digitalWrite(2,0),digitalWrite(3,1),Serial.print(“morado”);

if (key==’n’) digitalWrite(1,0),digitalWrite(2,1),digitalWrite(3,1),Serial.print(“celeste”);

if (key==’w’) digitalWrite(1,1),digitalWrite(2,1),digitalWrite(3,1),Serial.print(“blanco”);

if (key==’c’) digitalWrite(1,0),digitalWrite(2,0),digitalWrite(3,0),Serial.print(“apagado”);

Serial.print(“\n\r”); //por ultimo imprimimos el nombre del color seleccionado.

}

//vuelve a comenzar el loop

}

For more detail: RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller

The post RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller appeared first on PIC Microcontroller.


Knight Rider Light computer – version 2

$
0
0

This knight rider light computer is a successor of my first version of the Knight Rider. This version is much smaller and justifies the use of a microcontroller. The project is based on the PIC 12F629 microcontroller.

The hardware part

Unlike my previous project this light computer is build around the PIC12F629: a microcontroller with only 8 pins. It is shipped in a DIL-8 housing.

Knight Rider Light computer - version 2An external clock is not necessary: the chip has an internal 4 MHz oscillator. The reset circuit is not necessary either: I configured the PIC to use its internal reset circuit. So only 2 pins are needed to power the microcontroller. All other pins are available for I/O.

The schematic diagram can be kept very small. You only need the PIC12F629, eight LEDs, two resistors and a zenerdiode.

Each output of the PIC drives two LEDs. The cathode of all LEDs is common and connected to a single resistor. This is not a good design practice: each LED should have its own resistors as LEDs should never be placed in parallel. I did it anyway in this particular design because I needed a very compact solution (2 LEDs of the same type can slightly differ: they can have a different forward voltage. This can cause problems when they are placed in parallel).

The PIC’s GP03 port doesn’t drive any LEDs because it is solely an input port.

The circuit itself must be powered by a 9 VDC supply. This voltage is down sized to 4.7V by a zenerdiode D1 and resistor R2. Eventually they can be replaced by a 7805 regulator.

Possible PCB Layout

The image at the left illustrates how small this circuit could be when you create a PCB of it.Please note I drew this PCB very quick – I didn’t check it for errors as it is just an example. The PCB can’t be downloaded from this website.

Knight Rider Light computer - version 2 SchematicThe software part

I wrote the software in the C language. I used the (free) HI-TECH C language that was included with MPLab, a tool for the PIC microprocessors.

I used an array that contains all the 6 different output states. A loop is cycled: each cycle another output state is retrieved from the array.

I programmed this microcontroller with my very cheap Olimex USB PIC programmer [External]. This programmer can be used with Microchip MPLab so you don’t need any additional software.

 

For more detail: Knight Rider Light computer – version 2

The post Knight Rider Light computer – version 2 appeared first on PIC Microcontroller.

Pimp My Rocket (Espresso Machine)

$
0
0

Combining Coffee and Electronics – An Idea for a Project

Having played around with fixed function logic ICs, such as the Johnson counter used in the Spindicator project, I was keen to move on and experiment with programmable microcontrollers. I decided to obtain and play with some PICAXE chips, as they looked like they would provide an easy introduction to using microcontrollers. Soon enough I was flashing LEDs and building touch-activated computer power switches. But what I really wanted to try was using the chip to control the colour of an RGB LED. For a suitable project I came up with the idea of using a strip of RGB LEDs to provide accent lighting for my Rocket Espresso coffee machine, where the colour of the LED would depend on the temperature of the machine (specifically the inlet water to the brew head). I thought this had the potential to not only look pretty, but actually provide useful visual feedback on the all important brew water temperature. If you are reading this because you’re a coffee geek interested in E61 HX type espresso machines, you may want to skip the electronics part and read the last section to see how it turned out.

PICAXE is a low-cost, easy to use microcontroller system which uses a simple BASIC like programming language. I’m not going to provide a tutorial on how to use and program PICAXE chips in this post. If you are interested in that, the PICAXE website has excellent documentation, free programming software, and lots of circuit and code examples. There are several different PICAXE chips you can buy, with different numbers of inputs/outputs and different inbuilt functionality. The inbuilt PICAXE function that is central to this project is PWM (pulse-width modulation).

Pimp My Rocket (Espresso Machine)Controlling RGB LED Colour with PWM

An RGB LED is actually made of three LEDs under one lens, a red, blue and green LED (I’ll call these sub-LEDs). Each sub-LED can be switched on separately, so you can switch on blue and red to get purple for example. By switching each sub-LED completely on or off  you can make six colours (red, blue, green, purple, cyan and yellow). In order to gain access to a complete spectrum of colours, you need to be able to precisely control the brightness of each sub-LED, and the way to easily do that is via pulse-width modulation. PWM controls the brightness of an LED by switching it on and off very fast (20,ooo  times per second in my program), and controlling the amount of time it is on during each on-off cycle. The time for an on-off cycle is called the period (50µs in this case), and the time of the on pulse as a percentage of the period is called the duty cycle. So a for duty cycle of 50% at 20kHz, the LED will be switched on for 25µs, then off for 25µs. The switching is too fast for the eye to see, and so the overall result is that the LED will just look half as bright. Thus the LED brightness is directly proportional to the duty cycle. Most PICAXE microcontrollers have a PWM control function built in and accessible on one or more of the chip’s pins (see pinout diagrams in the PICAXE manual). Some PICAXE chips also have separate PWM control circuitry referred to as “HPWM”, or hardware PWM. The circuit and program described below uses the software PWM function. To control an RGB LED you need a chip with three (or more) independent PWM outputs such as the 14M2 or the 20M2. For this project I used the 20M2.

The Circuit

The circuit for this project is fairly simple as the PICAXE microcontroller does most of the work. For the LEDs I used a strip of six RGB LEDs. These  are pre-wired to a strip of adhesive backed flexible circuit board as shown in the photo above. They come on a long roll which can be cut to any multiple of three LEDs. Initially I was going to use two sets of six, one mounted under the Rocket on each side. Consequently, this circuit is designed to drive 12 LEDs, and can drive up to 15 using the transistors and resistors specified. When I tried it though, I didn’t like the look of the reflections of the individual LEDs off the stainless steel bench on which my machine sits. In the end I decided to use one strip of six mounted behind the machine and reflecting a nice diffused colour off the wall behind. The first circuit diagram below shows the power supply for the PICAXE and LEDs. The 12 volt DC input is supplied from a small 500 mA 12V plug-in power adaptor. This 12V input is used directly as the power supply for the LEDs, and also as the input to a 7805 voltage regulator with 5V output. The 5V rail powers the PICAXE chip and peripheral circuitry. I added a small LED to the 5V output as visual confirmation of PICAXE power on. The switch on the 12V input is to assist with programming the PICAXE (the best way to program the chip is to initiate transfer from the computer with the power off, then quickly switch the power on). To save space I implemented this switch with a simple two pin header and jumper, which is actually a bit fiddly. If I were to build it again I would use a proper PCB-mounted mini toggle switch.

The rest of the circuit is shown in the diagram below. It can be divided into four parts; the 20M2 PICAXE chip itself, the serial programming interface circuit, the thermistor voltage divider and the LED switching transistors.

The serial interface part of the circuit consists of two resistors and a 3.5mm stereo phono jack,  and is the standard minimum serial communication circuit as specified in the PICAXE literature. This can be used with either a simple serial cable (for connecting to a computer serial port, if your computer still has one), or the PICAXE USB  cable. For a temperature sensor I used a standard 10KOhm NTC thermistor (a component whose resistance changes in response to temperature). The thermistor forms half of a voltage divider with a 2.4K resistor, the divided voltage being read by the PICAXE analog to digital conversion function (ADC). The value of 2.4K was chosen to give a reasonably linear relationship between the divider voltage and thermistor temperature over the range of interest (25 to 120°C), as well as the greatest change in voltage over this range. This relationship can be calculated, and is shown in the plot below for my thermistor, which has a specified calibration constant (beta) of 4,100K.

The PICAXE ADC function converts the voltage at the input pin to a number between 0 and 255  in direct proportion to the voltage. This number is then used by the program to calculate and adjust the duty cycle of each sub-LED (red, blue and green). Because the LED strip requires a supply voltage of 12V, and because a PICAXE output can only sink or source up to 20mA, the LEDs are switched via three BC337 transistors (for my final 6-LED configuration, I could have also used BC548 transistors with say a 2KOhm base resistor). For the particular RGB LED strip I used, I measured the 100% duty cycle current per sub-LED at 6.2mA (red), 5.5mA (green) and 5.7mA (blue). Thus for a strip of six LEDs, the maximum current that any transistor will switch is 37mA. In the circuit shown above, the BC337’s can switch 100mA and remain saturated (probably more, but that’s a safe figure), which means that the circuit will safely switch a strip of 15 LEDs (they come in multiples of 3 remember). By reducing the base resistor value you could switch a lot more LEDs, as BC337’s have a maximum collector current of 800mA (you may need a gruntier 12V supply than I’ve specified though, and don’t forget the PICAXE per-output 20mA maximum current, with 90mA maximum per chip).

Pimp My Rocket (Espresso Machine) SchematicAfter going to some trouble to design a PCB layout in Illustrator, I decided that I couldn’t be bothered trying to etch a circuit board, so I made up the circuit using a prototype board and jumper wires, with screw terminals to connect the power supply, thermistor and LED strip. The board is illustrated below.

The rest of the circuit is shown in the diagram below. It can be divided into four parts; the 20M2 PICAXE chip itself, the serial programming interface circuit, the thermistor voltage divider and the LED switching transistors. The serial interface part of the circuit consists of two resistors and a 3.5mm stereo phono jack,  and is the standard minimum serial communication circuit as specified in the PICAXE literature. This can be used with either a simple serial cable (for connecting to a computer serial port, if your computer still has one), or the PICAXE USB  cable. For a temperature sensor I used a standard 10KOhm NTC thermistor (a component whose resistance changes in response to temperature). The thermistor forms half of a voltage divider with a 2.4K resistor, the divided voltage being read by the PICAXE analog to digital conversion function (ADC). The value of 2.4K was chosen to give a reasonably linear relationship between the divider voltage and thermistor temperature over the range of interest (25 to 120°C), as well as the greatest change in voltage over this range. This relationship can be calculated, and is shown in the plot below for my thermistor, which has a specified calibration constant (beta) of 4,100K.

 

For more detail: Pimp My Rocket (Espresso Machine)

The post Pimp My Rocket (Espresso Machine) appeared first on PIC Microcontroller.

Skateboard with PIC microcontroller and LEDs

$
0
0

What do you get when an Electrical Engineer builds a Skateboard from scratch for a 13 year old’s Christmas present? You get a skateboard with eight white LEDs (headlights), eight red LEDs (tailights) all controlled via PIC microntroller! And I might add, one very happy 13 year old, well as happy as a 13 year old can be. Following is how I modified a skateboard kit (from ROAROCKIT.COM), added LEDs to the front and back, added PIC circuit, and covered with a comic book and custom graphics.

Skateboard with PIC microcontroller and LEDs

Step 1: Start building the Skateboard

Starting with a laminate kit that was purchased from www.roarockit.com, laminate the first three layers together. The laminate kit from roarockit includes everything needed to laminate and form your own skateboard. This is the second kit that I have used from them and have been very happy with their product.
1. Place the first laminate on the foam mold.
2. Spread the skateboard glue on the first layer.
3. Place the second laminate on top of the first.
4. Spread the skateboard glue on the second layer.
5. Place the third laminate on top of the second.
6. Insert guide pin.
7. Slide the assembly into the netting.
8. Slide the assembly into the vacuum bag, seal the bag, and pump out all the air.

Skateboard with PIC microcontroller and LEDs Schemetic

Step 2: Create Channel for Wires

The wires that connect the LEDs at the front and the back of the Skateboard to the circuit board are installed in the fourth (middle) laminate of the skateboard.
1. After 24 hours remove the first three laminates from the vacuum bag.
2. Cut a channel/groove into the fourth laminate.
3. Add glue to the top of the first three laminate.
4. Place the fourth laminate on top of the assemble.
5. Place the assembly onto the foam mold, insert guide pin.
6. Place the entire assembly into the netting, then vacuum bag, and vacuum all the air out again.

 

For more detail: Skateboard with PIC microcontroller and LEDs

The post Skateboard with PIC microcontroller and LEDs appeared first on PIC Microcontroller.

Red Light for Astronomy Observing using PIC12F683

$
0
0

When doing astronomy observing at night preserving night vision is critical. This requires using the minimum amount of light that makes the sky charts readable. What is this minimum level depends on how dark are your surroundings, how much time you have spent in darkness, how well your eyes adapt for night vision, what type of charts are you using, what object are you observing, and so on. My old astronomy light was not very convenient – it only had two brightness levels, “too bright” and “not quite that bright”, and it was eating batteries like crazy. This one is a huge improvement and is a real pleasure to use.
Red Light
The PIC light has a brightness level that can be adjusted anywhere between comfortably bright and almost invisible with 128 steps of adjustment. Those 128 levels are distributed exponentially, to match the non-linear light sensitivity of the eye. In addition, there is a button for temporary brightness boost. This is convenient in the cases where you want to have the light really low, and bring it up a bit for a second only when you are trying to see some tiny detail on the star charts. The “boost” level is also fully adjustable.

The light consists of two parts – an old desk lamp with a patch of LCDs in place of the bulb, that is connected through an audio jack to a box containing the controller and the battery. I’m using an old computer mouse as controller/battery enclosure – this way, I can have the control buttons in a convenient place next to my charts. Instead of having an on/off switch, the light is turned on simply by plugging the lamp jack into the “mouse” (this required a slight modification of the female jack by bending a bit one of the contacts – you could figure it out by looking at the schematics). When I’m packing the light the mouse part goes into my crowded toolbox – with no on/off switch there is no danger that it will get turned on and I’ll discover the battery drained next time I need it.

 

For more detail: Red Light for Astronomy Observing using PIC12F683

The post Red Light for Astronomy Observing using PIC12F683 appeared first on PIC Microcontroller.

4-Digit 7-Segment display with 74HC595 shift register

$
0
0

There are many topics in this blog talking about the 7-segment display and how to interface it with different types of PIC microcontrollers. One of these topics shows how to interface PIC16F877A with a multiplexed 4-digit 7-segment display with the shift register 74HC164N.4-Digit 7-Segment display with 74HC595 shift register

There are many topics in this blog talking about the 7-segment display and how to interface it with different types of PIC microcontrollers. One of these topics shows how to interface PIC16F877A with a multiplexed 4-digit 7-segment display with the shift register 74HC164N.
In this topic we are going to see how to make a digital up/down counter using multiplexed 7-segment display with 74HC595 shift register and PIC16F877A microcontroller.
From the 74HC595 datasheet this shift register is a high speed, 8-stage serial shift register with a storage register and 3-state outputs. The registers have separate clocks.
Data is shifted on the positive-going transitions of the shift register clock input (SHCP). The data in each register is transferred to the storage register on a positive-going transition of the storage register clock input (STCP). If both clocks are connected together, the shift register will always be one clock pulse ahead of the storage register.
The following table shows the 74HC595 shift register pin-outs:74hc595_shift_register_pin_outs

7-Segment display with 74HC595 shift register:
The following circuit schematic shows a multiplexed 4 digits connected to the 74HC595 shift register. The type of the 7-segment display used in this example is common anode.
In the circuit there are two push buttons, these buttons are used to increment and decrement the displayed number.

 

For more detail: 4-Digit 7-Segment display with 74HC595 shift register

The post 4-Digit 7-Segment display with 74HC595 shift register appeared first on PIC Microcontroller.

Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler

$
0
0
The easiest way to interface 7-segment display with PIC12F1822 microcontroller is to add a serial-in parallel-out shift register. The adding of the shift register minimizes the number of pins used by the 7-segment display. This topic shows how to make a 3-digit digital counter with multiplexing and 74HC164 shift register using PIC16F877A and CCS PIC C compiler.Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler
Interfacing PIC12F1822 with 7-segment display circuit:
Here is an example shows how to make a digital up counter where the number is displayed on a 7 segment display uses multiplexing technique with shift register. 
Example circuit schematic is shown below where a common anode 7-segment display and 74HC164N shift register are used.
Other shift registers such as 74HC595 or CD4094 can be used in this project.
The displayed number can be incremented using the button which is connected to RA3 pin. Schematic Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler
Internal oscillator of the microcontroller is used @ 8MHz and MCLR pin function is disabled.

The push button is connected to RA3 pin. The shift register used is 74HC164 but other types can work properly like 74HC595 or CD4094.
In this example all pins of PIC12F1822 are used and there is no free pin.
Interfacing PIC12F1822 with 7-segment display CCS C code:

The post Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler appeared first on PIC Microcontroller.

Easy Way to Design an Automatic Driverless Train

$
0
0

Every one in the metro cities like Kolkata, Delhi enjoying the luxuries of the metro train ever spared a thought about the train? No, then let me give you a brief idea about the driverless automatic driven and controlled train. But before that let us have a brief recall about types of metro automation.

The Driver Controlled Mode:

In conventional modes, it’s the manual driver who drives the train and controls the train motion using the stationary light signals.

Easy Way to Design an Automatic Driverless Train

The Partially Automatic Mode:

In this mode, the driver drives the train while an external control system is used to constantly monitor the speed and acceleration of the train and provide required feedback to the driver.

Driverless Mode:

The whole operation and maintenance of the train is done automatically without any human intervention. The train stops and starts automatically and the doors are closed and opened automatically.

So, now let us fix our attention to the last mode i.e. The Driverless Mode

In a fully automatic driverless train, the control is done through a Communication based train control where a trackside computer is used to monitor the train running on the assigned line and convey this information to the centralized computer. The train is controlled by the automatic train control system.

Designing a Basic Prototype of a Automatic Driverless Train

The design will include the following components:

  • A rectangular body which holds all the other robotic components like the control circuit, the door etc.
  • A sliding door prototype
  • A couple of IR LED and photodiode arrangement
  • A control circuitry using a Microcontroller

Working of the Basic Prototype:

So let us see how our basic prototype works does:

  • The Automatic platform sensing and Door control system: It consists of an IR LED and a photodiode system. When the sensor senses the coming of the station, the motor driver automatically drives the motor such that the train comes to a halt and the door is opened when a person is sensed.
  • Passenger counter system: The train is also equipped with a passenger counter system which counts the number of passengers entering the train and when the count reaches a certain limit the door is closed automatically and the train will start moving after a certain time limit.

Easy Way to Design an Automatic Driverless Train Schematic

How to controls the Train Prototype:

  • Controlling the movement of the train: Normally when the train is moving, the IR LED-photodiode arrangement is placed such that both are placed parallel to each other and thus as the photodiode doesn’t gets the light pulses, it doesn’t conducts and as a result the microcontroller will get a high signal. Now as the train approaches a station, the IR light from the IR LED gets reflected by any object (suppose the station signal) and the reflected light falls on the photodiode, causing it to conduct and thus an interrupt low signal is given to the microcontroller through the transistor. The microcontroller is programmed so as to send signals to the motor driver to stop the motors. The operation of the motor is driven by the motor drive IC; here two stations are connected to the microcontroller through the motor drive.

 

For more detail: Easy Way to Design an Automatic Driverless Train

The post Easy Way to Design an Automatic Driverless Train appeared first on PIC Microcontroller.


Cheap PIC Programmer

$
0
0

This programmer works only with PIC16F84 but it’s great because it never causes errors and works with almost all computers,unlike some other homemade programmers.

Step 1: Step one : Materials

For this programmer you won’t need many materials.In fact , you will find all you need in your local electronics shop 😉

So here’s what materials you will need:
-IC Board
-RS232(Serial) FEMALE connector
-BC547B or 2N3904 (I couldn’t find the BC so i used 2N3904,it works great)
-5.1 V diode
-100 uF 16V Electrolytic Capacitor

Cheap PIC Programmer
-18 PIN IC Socket
-10Kohm resistor
-15Kohm resistor
OPTIONAL[
-Flashing red LED / 2.1 V Standard Red LED
-3.3Kohm Resistor]
-PIC16F84A Microcontroller
Tools:
-Soldering Iron
-Scissors or any other cuting tool

OPTIONAL[
-Hot glue gun]

Step 2: Step two : The scheme

This is the scheme you will use for your programmer.
As you can see , i tagged two connection in the scheme as “Optional point” one and two .
Those are the points where you will connect the “Optional” circuit i will show you in step 3

Step 3: Step three : The optional circuit

The optional circuit consists of the LED and 3.3 Kohm resistor marked as optional in step one.
One pin of the resistor goes in the Optional point one , the other pin goes in the anode(+) of the LED.
The cathone(-) pin of the LED will go in Optional point two.
If you don’t understand , use the ellipse marked area of the scheme below.

Cheap PIC Programmer Schematic

Step 4: Step four : Let’s build it !

Ok , you’ve got all you need.Now it’s time to build it.
DON’T CUT THE IC BOARD YET!
First solder the RS232 female connector in a corner of your IC Board.If you don’t know what are the connectors of the RS232 i uploaded an image.
After you soldered the RS232 , solder all elements according to the schematic,and then cut the board.
After you cut the board,secure all solderings with hot glue (optional).
You’re done!

 

For more detail: Cheap PIC Programmer

The post Cheap PIC Programmer appeared first on PIC Microcontroller.

RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller

$
0
0

RGB REMOTE (pinguino+web+linksys)

This project has several uses, it is basically a way to control an RGB LED group (tricolor with common ground) via a web page to select which color we want to show.

RGB REMOTE
It may be a way to harmonize a room, change the color of a swimming pool or just fooling aroun

Step 1

RGB REMOTE webserver and serial connection

RGB REMOTE webserver and serial connection

In my case the web server is in Linksys router which I have “hacked / tunner” and installed a version of Linux opensource … in this case OpenWRT 9.02, with this special version for this type of equipment, It can be more flexible than the original software. Installing LUA and one webserver and I have all that I will need.

As to the little memory space of this team, to host my website, I have included a change and I have installed a 1GB SD card as hard drive so you can play and install things without fear to occupy the 5Mb which has by default. I’ve also created two output interfaces for internal serial ports by default has LINKSYS and that, in principle are control consoles, modifying a bit its used to connect any computer with RS232 communication.

Step 2

RGB REMOTE pinguino

I use a hardware interface with the 18F2550 microcontroller PINGUINO PIC Firmware v2, 12. This has a basic programming, which attempts to transfer via serial communication from the web server and has scripts that send orders and data via serial port. For example by sending the character “R” means to tell the microcontroller that the LEDs turn RED ONLY. And so with all the colors and combinations.

link original http://www.hackinglab.org/pinguino/index_pinguino.html
link Madrid http://pinguino.walii.es

The program basically tells the microcontroller that the serial port and listen when you get status R eg send a pulse to continuous 5volts particular output for the red LEDs. And finally sent to the serial port the color name that is kindled.
The code is as follows. USE PINGUINO GUI to programate it.
// Prueba de Puerto serie comandando RGB

// walii.es 2010

//aquí agregamos las posibles variables.

int i; //para nuestro contador de puertos

int key; //para la tecla que escucha por el Puerto serie.

void setup()

{

//Aquí configuramos los puertos de salida para que inicien

//en estado de SALIDA y APAGADOs.

for (i=1;i<4;i++){

pinMode(i,OUTPUT);

digitalWrite(i,LOW);

}

//Aquí configuramos el Puerto serie, para que escuche peticiones a 9600bps,

//suficiente para este proyecto.

Serial.begin(9600);

}

//Y por acá podemos ver la configuración de comandos a escuchar en el Puerto

//serie y hacer lo necesario para iniciar los leds que correspondan a la acción

void loop()

{

if Serial.available()

{

key=Serial.read(); //escucha el Puerto serie…

if (key==’r’) digitalWrite(1,1),digitalWrite(2,0),digitalWrite(3,0),Serial.print(“rojo”);

if (key==’v’) digitalWrite(1,0),digitalWrite(2,1),digitalWrite(3,0),Serial.print(“verde”);

if (key==’a’) digitalWrite(1,0),digitalWrite(2,0),digitalWrite(3,1),Serial.print(“azul”);

if (key==’m’) digitalWrite(1,1),digitalWrite(2,1),digitalWrite(3,0),Serial.print(“marron”);

if (key==’b’) digitalWrite(1,1),digitalWrite(2,0),digitalWrite(3,1),Serial.print(“morado”);

if (key==’n’) digitalWrite(1,0),digitalWrite(2,1),digitalWrite(3,1),Serial.print(“celeste”);

if (key==’w’) digitalWrite(1,1),digitalWrite(2,1),digitalWrite(3,1),Serial.print(“blanco”);

if (key==’c’) digitalWrite(1,0),digitalWrite(2,0),digitalWrite(3,0),Serial.print(“apagado”);

Serial.print(“\n\r”); //por ultimo imprimimos el nombre del color seleccionado.

}

//vuelve a comenzar el loop

}

For more detail: RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller

The post RGB REMOTE (pinguino+web+linksys) using PIC18F2550 microcontroller appeared first on PIC Microcontroller.

Knight Rider Light computer – version 2

$
0
0

This knight rider light computer is a successor of my first version of the Knight Rider. This version is much smaller and justifies the use of a microcontroller. The project is based on the PIC 12F629 microcontroller.

The hardware part

Unlike my previous project this light computer is build around the PIC12F629: a microcontroller with only 8 pins. It is shipped in a DIL-8 housing.

Knight Rider Light computer - version 2An external clock is not necessary: the chip has an internal 4 MHz oscillator. The reset circuit is not necessary either: I configured the PIC to use its internal reset circuit. So only 2 pins are needed to power the microcontroller. All other pins are available for I/O.

The schematic diagram can be kept very small. You only need the PIC12F629, eight LEDs, two resistors and a zenerdiode.

Each output of the PIC drives two LEDs. The cathode of all LEDs is common and connected to a single resistor. This is not a good design practice: each LED should have its own resistors as LEDs should never be placed in parallel. I did it anyway in this particular design because I needed a very compact solution (2 LEDs of the same type can slightly differ: they can have a different forward voltage. This can cause problems when they are placed in parallel).

The PIC’s GP03 port doesn’t drive any LEDs because it is solely an input port.

The circuit itself must be powered by a 9 VDC supply. This voltage is down sized to 4.7V by a zenerdiode D1 and resistor R2. Eventually they can be replaced by a 7805 regulator.

Possible PCB Layout

The image at the left illustrates how small this circuit could be when you create a PCB of it.Please note I drew this PCB very quick – I didn’t check it for errors as it is just an example. The PCB can’t be downloaded from this website.

Knight Rider Light computer - version 2 SchematicThe software part

I wrote the software in the C language. I used the (free) HI-TECH C language that was included with MPLab, a tool for the PIC microprocessors.

I used an array that contains all the 6 different output states. A loop is cycled: each cycle another output state is retrieved from the array.

I programmed this microcontroller with my very cheap Olimex USB PIC programmer [External]. This programmer can be used with Microchip MPLab so you don’t need any additional software.

 

For more detail: Knight Rider Light computer – version 2

Current Project / Post can also be found using:

  • knight rider circuit pcb
  • knight rider computer

The post Knight Rider Light computer – version 2 appeared first on PIC Microcontroller.

Pimp My Rocket (Espresso Machine)

$
0
0

Combining Coffee and Electronics – An Idea for a Project

Having played around with fixed function logic ICs, such as the Johnson counter used in the Spindicator project, I was keen to move on and experiment with programmable microcontrollers. I decided to obtain and play with some PICAXE chips, as they looked like they would provide an easy introduction to using microcontrollers. Soon enough I was flashing LEDs and building touch-activated computer power switches. But what I really wanted to try was using the chip to control the colour of an RGB LED. For a suitable project I came up with the idea of using a strip of RGB LEDs to provide accent lighting for my Rocket Espresso coffee machine, where the colour of the LED would depend on the temperature of the machine (specifically the inlet water to the brew head). I thought this had the potential to not only look pretty, but actually provide useful visual feedback on the all important brew water temperature. If you are reading this because you’re a coffee geek interested in E61 HX type espresso machines, you may want to skip the electronics part and read the last section to see how it turned out.

PICAXE is a low-cost, easy to use microcontroller system which uses a simple BASIC like programming language. I’m not going to provide a tutorial on how to use and program PICAXE chips in this post. If you are interested in that, the PICAXE website has excellent documentation, free programming software, and lots of circuit and code examples. There are several different PICAXE chips you can buy, with different numbers of inputs/outputs and different inbuilt functionality. The inbuilt PICAXE function that is central to this project is PWM (pulse-width modulation).

Pimp My Rocket (Espresso Machine)Controlling RGB LED Colour with PWM

An RGB LED is actually made of three LEDs under one lens, a red, blue and green LED (I’ll call these sub-LEDs). Each sub-LED can be switched on separately, so you can switch on blue and red to get purple for example. By switching each sub-LED completely on or off  you can make six colours (red, blue, green, purple, cyan and yellow). In order to gain access to a complete spectrum of colours, you need to be able to precisely control the brightness of each sub-LED, and the way to easily do that is via pulse-width modulation. PWM controls the brightness of an LED by switching it on and off very fast (20,ooo  times per second in my program), and controlling the amount of time it is on during each on-off cycle. The time for an on-off cycle is called the period (50µs in this case), and the time of the on pulse as a percentage of the period is called the duty cycle. So a for duty cycle of 50% at 20kHz, the LED will be switched on for 25µs, then off for 25µs. The switching is too fast for the eye to see, and so the overall result is that the LED will just look half as bright. Thus the LED brightness is directly proportional to the duty cycle. Most PICAXE microcontrollers have a PWM control function built in and accessible on one or more of the chip’s pins (see pinout diagrams in the PICAXE manual). Some PICAXE chips also have separate PWM control circuitry referred to as “HPWM”, or hardware PWM. The circuit and program described below uses the software PWM function. To control an RGB LED you need a chip with three (or more) independent PWM outputs such as the 14M2 or the 20M2. For this project I used the 20M2.

The Circuit

The circuit for this project is fairly simple as the PICAXE microcontroller does most of the work. For the LEDs I used a strip of six RGB LEDs. These  are pre-wired to a strip of adhesive backed flexible circuit board as shown in the photo above. They come on a long roll which can be cut to any multiple of three LEDs. Initially I was going to use two sets of six, one mounted under the Rocket on each side. Consequently, this circuit is designed to drive 12 LEDs, and can drive up to 15 using the transistors and resistors specified. When I tried it though, I didn’t like the look of the reflections of the individual LEDs off the stainless steel bench on which my machine sits. In the end I decided to use one strip of six mounted behind the machine and reflecting a nice diffused colour off the wall behind. The first circuit diagram below shows the power supply for the PICAXE and LEDs. The 12 volt DC input is supplied from a small 500 mA 12V plug-in power adaptor. This 12V input is used directly as the power supply for the LEDs, and also as the input to a 7805 voltage regulator with 5V output. The 5V rail powers the PICAXE chip and peripheral circuitry. I added a small LED to the 5V output as visual confirmation of PICAXE power on. The switch on the 12V input is to assist with programming the PICAXE (the best way to program the chip is to initiate transfer from the computer with the power off, then quickly switch the power on). To save space I implemented this switch with a simple two pin header and jumper, which is actually a bit fiddly. If I were to build it again I would use a proper PCB-mounted mini toggle switch.

The rest of the circuit is shown in the diagram below. It can be divided into four parts; the 20M2 PICAXE chip itself, the serial programming interface circuit, the thermistor voltage divider and the LED switching transistors.

The serial interface part of the circuit consists of two resistors and a 3.5mm stereo phono jack,  and is the standard minimum serial communication circuit as specified in the PICAXE literature. This can be used with either a simple serial cable (for connecting to a computer serial port, if your computer still has one), or the PICAXE USB  cable. For a temperature sensor I used a standard 10KOhm NTC thermistor (a component whose resistance changes in response to temperature). The thermistor forms half of a voltage divider with a 2.4K resistor, the divided voltage being read by the PICAXE analog to digital conversion function (ADC). The value of 2.4K was chosen to give a reasonably linear relationship between the divider voltage and thermistor temperature over the range of interest (25 to 120°C), as well as the greatest change in voltage over this range. This relationship can be calculated, and is shown in the plot below for my thermistor, which has a specified calibration constant (beta) of 4,100K.

The PICAXE ADC function converts the voltage at the input pin to a number between 0 and 255  in direct proportion to the voltage. This number is then used by the program to calculate and adjust the duty cycle of each sub-LED (red, blue and green). Because the LED strip requires a supply voltage of 12V, and because a PICAXE output can only sink or source up to 20mA, the LEDs are switched via three BC337 transistors (for my final 6-LED configuration, I could have also used BC548 transistors with say a 2KOhm base resistor). For the particular RGB LED strip I used, I measured the 100% duty cycle current per sub-LED at 6.2mA (red), 5.5mA (green) and 5.7mA (blue). Thus for a strip of six LEDs, the maximum current that any transistor will switch is 37mA. In the circuit shown above, the BC337’s can switch 100mA and remain saturated (probably more, but that’s a safe figure), which means that the circuit will safely switch a strip of 15 LEDs (they come in multiples of 3 remember). By reducing the base resistor value you could switch a lot more LEDs, as BC337’s have a maximum collector current of 800mA (you may need a gruntier 12V supply than I’ve specified though, and don’t forget the PICAXE per-output 20mA maximum current, with 90mA maximum per chip).

Pimp My Rocket (Espresso Machine) SchematicAfter going to some trouble to design a PCB layout in Illustrator, I decided that I couldn’t be bothered trying to etch a circuit board, so I made up the circuit using a prototype board and jumper wires, with screw terminals to connect the power supply, thermistor and LED strip. The board is illustrated below.

The rest of the circuit is shown in the diagram below. It can be divided into four parts; the 20M2 PICAXE chip itself, the serial programming interface circuit, the thermistor voltage divider and the LED switching transistors. The serial interface part of the circuit consists of two resistors and a 3.5mm stereo phono jack,  and is the standard minimum serial communication circuit as specified in the PICAXE literature. This can be used with either a simple serial cable (for connecting to a computer serial port, if your computer still has one), or the PICAXE USB  cable. For a temperature sensor I used a standard 10KOhm NTC thermistor (a component whose resistance changes in response to temperature). The thermistor forms half of a voltage divider with a 2.4K resistor, the divided voltage being read by the PICAXE analog to digital conversion function (ADC). The value of 2.4K was chosen to give a reasonably linear relationship between the divider voltage and thermistor temperature over the range of interest (25 to 120°C), as well as the greatest change in voltage over this range. This relationship can be calculated, and is shown in the plot below for my thermistor, which has a specified calibration constant (beta) of 4,100K.

 

For more detail: Pimp My Rocket (Espresso Machine)

The post Pimp My Rocket (Espresso Machine) appeared first on PIC Microcontroller.

Skateboard with PIC microcontroller and LEDs

$
0
0

What do you get when an Electrical Engineer builds a Skateboard from scratch for a 13 year old’s Christmas present? You get a skateboard with eight white LEDs (headlights), eight red LEDs (tailights) all controlled via PIC microntroller! And I might add, one very happy 13 year old, well as happy as a 13 year old can be. Following is how I modified a skateboard kit (from ROAROCKIT.COM), added LEDs to the front and back, added PIC circuit, and covered with a comic book and custom graphics.

Skateboard with PIC microcontroller and LEDs

Step 1: Start building the Skateboard

Starting with a laminate kit that was purchased from www.roarockit.com, laminate the first three layers together. The laminate kit from roarockit includes everything needed to laminate and form your own skateboard. This is the second kit that I have used from them and have been very happy with their product.
1. Place the first laminate on the foam mold.
2. Spread the skateboard glue on the first layer.
3. Place the second laminate on top of the first.
4. Spread the skateboard glue on the second layer.
5. Place the third laminate on top of the second.
6. Insert guide pin.
7. Slide the assembly into the netting.
8. Slide the assembly into the vacuum bag, seal the bag, and pump out all the air.

Skateboard with PIC microcontroller and LEDs Schemetic

Step 2: Create Channel for Wires

The wires that connect the LEDs at the front and the back of the Skateboard to the circuit board are installed in the fourth (middle) laminate of the skateboard.
1. After 24 hours remove the first three laminates from the vacuum bag.
2. Cut a channel/groove into the fourth laminate.
3. Add glue to the top of the first three laminate.
4. Place the fourth laminate on top of the assemble.
5. Place the assembly onto the foam mold, insert guide pin.
6. Place the entire assembly into the netting, then vacuum bag, and vacuum all the air out again.

 

For more detail: Skateboard with PIC microcontroller and LEDs

The post Skateboard with PIC microcontroller and LEDs appeared first on PIC Microcontroller.

Red Light for Astronomy Observing using PIC12F683

$
0
0

When doing astronomy observing at night preserving night vision is critical. This requires using the minimum amount of light that makes the sky charts readable. What is this minimum level depends on how dark are your surroundings, how much time you have spent in darkness, how well your eyes adapt for night vision, what type of charts are you using, what object are you observing, and so on. My old astronomy light was not very convenient – it only had two brightness levels, “too bright” and “not quite that bright”, and it was eating batteries like crazy. This one is a huge improvement and is a real pleasure to use.
Red Light
The PIC light has a brightness level that can be adjusted anywhere between comfortably bright and almost invisible with 128 steps of adjustment. Those 128 levels are distributed exponentially, to match the non-linear light sensitivity of the eye. In addition, there is a button for temporary brightness boost. This is convenient in the cases where you want to have the light really low, and bring it up a bit for a second only when you are trying to see some tiny detail on the star charts. The “boost” level is also fully adjustable.

The light consists of two parts – an old desk lamp with a patch of LCDs in place of the bulb, that is connected through an audio jack to a box containing the controller and the battery. I’m using an old computer mouse as controller/battery enclosure – this way, I can have the control buttons in a convenient place next to my charts. Instead of having an on/off switch, the light is turned on simply by plugging the lamp jack into the “mouse” (this required a slight modification of the female jack by bending a bit one of the contacts – you could figure it out by looking at the schematics). When I’m packing the light the mouse part goes into my crowded toolbox – with no on/off switch there is no danger that it will get turned on and I’ll discover the battery drained next time I need it.

 

For more detail: Red Light for Astronomy Observing using PIC12F683

Current Project / Post can also be found using:

  • Small Flat LEDs for microchip programming
  • home automation with pic16f628a
  • led snowflake project using microcontroller
  • pic based home automation

The post Red Light for Astronomy Observing using PIC12F683 appeared first on PIC Microcontroller.

4-Digit 7-Segment display with 74HC595 shift register

$
0
0

There are many topics in this blog talking about the 7-segment display and how to interface it with different types of PIC microcontrollers. One of these topics shows how to interface PIC16F877A with a multiplexed 4-digit 7-segment display with the shift register 74HC164N.4-Digit 7-Segment display with 74HC595 shift register

There are many topics in this blog talking about the 7-segment display and how to interface it with different types of PIC microcontrollers. One of these topics shows how to interface PIC16F877A with a multiplexed 4-digit 7-segment display with the shift register 74HC164N.
In this topic we are going to see how to make a digital up/down counter using multiplexed 7-segment display with 74HC595 shift register and PIC16F877A microcontroller.
From the 74HC595 datasheet this shift register is a high speed, 8-stage serial shift register with a storage register and 3-state outputs. The registers have separate clocks.
Data is shifted on the positive-going transitions of the shift register clock input (SHCP). The data in each register is transferred to the storage register on a positive-going transition of the storage register clock input (STCP). If both clocks are connected together, the shift register will always be one clock pulse ahead of the storage register.
The following table shows the 74HC595 shift register pin-outs:74hc595_shift_register_pin_outs

7-Segment display with 74HC595 shift register:
The following circuit schematic shows a multiplexed 4 digits connected to the 74HC595 shift register. The type of the 7-segment display used in this example is common anode.
In the circuit there are two push buttons, these buttons are used to increment and decrement the displayed number.

 

For more detail: 4-Digit 7-Segment display with 74HC595 shift register

Current Project / Post can also be found using:

  • how to use 74Hc595 in multiplexing of seven segment using PIC MICRO

The post 4-Digit 7-Segment display with 74HC595 shift register appeared first on PIC Microcontroller.


Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler

$
0
0
The easiest way to interface 7-segment display with PIC12F1822 microcontroller is to add a serial-in parallel-out shift register. The adding of the shift register minimizes the number of pins used by the 7-segment display. This topic shows how to make a 3-digit digital counter with multiplexing and 74HC164 shift register using PIC16F877A and CCS PIC C compiler.Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler
Interfacing PIC12F1822 with 7-segment display circuit:
Here is an example shows how to make a digital up counter where the number is displayed on a 7 segment display uses multiplexing technique with shift register. 
Example circuit schematic is shown below where a common anode 7-segment display and 74HC164N shift register are used.
Other shift registers such as 74HC595 or CD4094 can be used in this project.
The displayed number can be incremented using the button which is connected to RA3 pin. Schematic Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler
Internal oscillator of the microcontroller is used @ 8MHz and MCLR pin function is disabled.

The push button is connected to RA3 pin. The shift register used is 74HC164 but other types can work properly like 74HC595 or CD4094.
In this example all pins of PIC12F1822 are used and there is no free pin.
Interfacing PIC12F1822 with 7-segment display CCS C code:

Current Project / Post can also be found using:

  • interfacing 7segment display with pic12f1822 pic microcontroler project components
  • controlling rgb led microchip
  • pic microcontroller circuit using ccs compiler

The post Interfacing 7-segment display with PIC12F1822 using CCS PIC C compiler appeared first on PIC Microcontroller.

Automatic traffic light using PIC16F877A Microcontroller

$
0
0

The objective of this project is to design a traffic light control system. This traffic light controller is used at the intersection that consists of a main road and two side roads.

A four way traffic light control system with count down timers is to be designed and constructed. The system is to be developed with the PIC16f877A chip being the microcontroller that is programmed to do the task of controlling. Figure shows the drawing of the 4-way junction, where each way has its traffic light and counter.

Low power LEDs are used for every traffic light with different colors, namely red, yellow and green. The red LED indicates “stop driving”, the yellow LED indicates “start stopping” and the green LED indicates “drive”. The sequence of altering the LEDs according to their color is as shown in the figure below: Green-Yellow-Red-Green. Twelve LEDs are used;three to each traffic light.

 

7-segment LED displays are used to show the current count value. Since all of the traffic lights are working simultaneously, each one is to display a different digit than the other. When a traffic light is tuned green, its corresponding 7-segment displays start counting down from a specific value and decrements until zero is reached. After this the counter starts by a new count value at the moment the yellow light turns on. When the red light turns on after the yellow took its time, the count continues to decrement until reaching zero. This means that the same 7-segments, on each traffic light, are used to display the count when cars are allowed and not allowed to pass. In terms of counting, the yellow and red are considered one set while the green is another set.

PDL (Program Description Language) :

  • Turn on led_Red1
  • Turn on led_Green2
  • Wait 30 seconds
  • Turn on led_Yellow1
  • Turn on led_Yellow2
  • Wait 3 seconds
  • Turn on led_Red2
  • Turn on led_Green1
  • Wait 20 seconds
  • Turn on led_Yellow1
  • Turn on led_Yellow2
  • Wait 3 seconds

Software Development
The code developed for the PIC is written in the C language. The compiler used to write the C code is mikroC PRO for PIC V. 6.6.3. After the c code is successfully compiled, a HEX file is generated.

Automatic traffic light using PIC16F877A Microcontroller (Code)


/*
* Project name:
Automatic traffic light control with microcontroller
* Copyright:
(c) lET'S THINk BINARY, 2017.
* Revision History:
V0.0
* Description:
Automatic traffic light using PIC Microcontroller .
* Test configuration:
MCU: PIC16f877a
Oscillator: 8.0000 MHz Crystal
SW: mikroC PRO for PIC
http://www.mikroe.com/mikroc/pic/
* NOTES:
- This Our Group (thanks to join and participate) :
https://www.facebook.com/groups/816450708460518/
- Facebook page (thanks to like and share) :
https://www.facebook.com/Lets-Think-Binary-1728910547340654/
- Youtube Channel (thanks to subscribe) :
https://www.youtube.com/channel/UCTIAzxEkyeA6HTvl_VHd-Tw
*/
#include "Display_Utils.h"
unsigned short shifter, portd_index;
unsigned short portd_array[4];
int digit,digit1, digit10,i;
sbit led_Green1 at portC.b0;
sbit led_Yellow1 at portC.b1;
sbit led_Red1 at portC.b2;
sbit led_Green2 at portC.b5;
sbit led_Yellow2 at portC.b6;
sbit led_Red2 at portC.b7;
void interrupt() {
PORTA = 0; // Turn off all 7seg displays
PORTD = portd_array[portd_index]; // bring appropriate value to PORTD
PORTA = shifter; // turn on appropriate 7seg. display
// move shifter to next digit
shifter <<= 1; if (shifter > 8u)
shifter = 1;
// increment portd_index
portd_index++ ;
if (portd_index > 3u)
portd_index = 0; // turn on 1st, turn off 2nd 7seg.
TMR0 = 0; // reset TIMER0 value
TMR0IF_bit = 0; // Clear TMR0IF
}
void display(){
digit = i % 10u;
digit1 = conversion(digit); // prepare ones digit
portd_array[0] = conversion(digit); // and store it to PORTD array
portd_array[2] = conversion(digit);
digit = (char)(i / 10u) % 10u;
digit10 = conversion(digit); // prepare tens digit
portd_array[1] = conversion(digit); // and store it to PORTD array
portd_array[3] = conversion(digit); // and store it to PORTD array
}
void main(){
ADCON1=6; // Configure PORTX pins as digital
TRISA = 0; // Configure PORTA as output
PORTA = 0; // Clear PORTA
TRISD = 0; // Configure PORTD as output
PORTD = 0; // Clear PORTD
TRISC=0;
PORTC=0;
OPTION_REG=0x80; // Timer0 settings
TMR0 = 0; // clear TMROL
digit = 0;
portd_index = 0;
shifter = 1;
GIE_bit = 1; // Enaable GIE
TMR0IE_bit = 1; // Enaable T0IE
//INTCON = 0xA0; // Enaable GIE,T0IE
do{
// PHASE1
PORTC=0;
i=30;
for(i;i>=0;i--){
display();
led_Green1=1; led_Red2=1;
delay_ms(400);
}
//PHASE2
PORTC=0;
i=3;
for(i;i>=0;i--){
display();
led_Yellow2=1;led_Yellow1=1;
delay_ms(400);
}
//PHASE3
PORTC=0;
i=20;
for(i;i>=0;i--){
display();
PORTC=0;
led_Green2=1; led_Red1=1;
delay_ms(400);
}
//PHASE4
PORTC=0;
i=3;
for(i;i>=0;i--){
display();
led_Yellow2=1;led_Yellow1=1;
delay_ms(400);
}
}while(1); // infinite loop
} // end of program

Automatic traffic light using PIC16F877A Microcontroller (Schematic Diagram)

Automatic traffic light using PIC16F877A Microcontroller schematic diagram

Traffic light controller using PIC microcontroller

Results :

Compile the PIC code and get the hex file from it.
For simulating with PROTEUS ISIS hit run button and then you will get above output.

Resource :

You can download the MikroC Source Code and Proteus files etc from this link traffic light controller :
This Our Group (thanks to join and participate) : https://www.facebook.com/groups/816450708460518/
Facebook page : https://www.facebook.com/Lets-Think-Binary-1728910547340654/
Youtube Channel (thanks to subscribe) :
https://www.youtube.com/channel/UCTIAzxEkyeA6HTvl_VHd-Tw

 

Current Project / Post can also be found using:

  • microcontroller led projects

The post Automatic traffic light using PIC16F877A Microcontroller appeared first on PIC Microcontroller.

parking management system project using pic microcontroller

$
0
0

parking management system, we aim to create a smart parking system which will not only calculate the total capacity for cars in the parking area but will also direct the cars to an empty spot where they can park their cars in an orderly fashion. This parking management system will require at least 6-8 proximity sensors to detect the presence or absence of a car and also to detect if a car has entered the parking area. Secondly we will also use 18 red LEDS which will be used to guide the driver to a vacant space in the parking lot. Lastly we will use one red and one green LED which will tell the driver when he/she has to enter the car in the parking lot (to avoid congestion).

Working of parking management system

We will use a micro controller (PIC18F46K22) to control the working of our project. When a car enters the parking area, the IR sensor placed at the entrance will give a high at its output. This output is then fed to the interrupt pin of the microcontroller and after executing some code in the interrupt service routine, the micro controller decrements the remaining capacity and gives an intelligent output to the guide the car at its parking spot.  This output is given in the form of blinking LEDs. When a parking space is occupied, the path (made by blinking LEDS) changes automatically so that it points to a new vacant location. When all parking locations are occupied, the LCD gives a output of “Parking Full !”.  A green LED lights up initially to indicate that a car can enter the parking lot.

The moment it enters, the green LED switches off and a red LED turns on.  This red LED indicates that the next car cannot enter and it stays that way until the car (which has entered) has parked to an empty location. IR sensors are also placed at each parking spot. These sensors are needed to tell the microcontroller whether a parking space is occupied or not. This is achieved by giving the output of the sensor to Port B of the microcontroller (Interfacing).

Circuit Diagram of parking management system

Circuit diagram of parking management system is given below. It is just a demo of parking management system so for practical purposes one need to implement larger circuit than this.

Circuit Diagram of parking management system

Explanation of Circuit Diagram of parking management system

For this project we have used all ports of the microcontroller except for PORT E. For inputs form IR sensors, we have used logic states where ‘1’ means that a car is parked at that spot and ‘0’ means the the parking space is unoccupied. Port C and Port A are interfaced with the microcontroller using SIL connectors. Port C and  Port A are used as output ports and they are used to light up the LED path and to control the green/red LED at the entrance. Port B is also interfaced with the micro controller using a 8-pin SIL male connector, Port B is used for input to the microcontroller . Each pin of port B is connected to the output of one of the IR sensors. (6 sensors for parking + 1 sensor for entry + 1 sensor for exit) . The LED path can be thought of as 3×3 matrix where a set of two LEDs represent a single element of the matrix. The memory clear/reset pin is always given a high at input because otherwise the simulation does not run.  Lastly Port D is interfaced to the LCD and will be used to show the capacity of the parking area.

Code for Project parking management system

Code for parking management system is not free of cost. If you are interested to purchase code, contact me at bilalmalikuet@gmail.com

Explanation for Code of parking management system

Essentially the code works using interrupts. Interrupts are used to handle entry and exit of cars on a priority bases and they trigger execution of certain functions which run in a while loop in the main code.The parking lot is divided into a 3×2 matrix. A 1 in a matrix represents a car being parked there and it is updated once every time in a while loop. When a car enters and a path has to be made, the matrix is expanded into a 3×3 matrix. A 1 in the LED matrix indicates an empty parking spot.The matrix is biased to always give the closest parking spot to the exit. A path of 1’s is created from the empty spot to the entrance and is refreshed every cycle. So if a parked car leaves from a spot closer to the exit the path reroutes to that empty spot.

Read more: parking management system project using pic microcontroller

Current Project / Post can also be found using:

  • led snowflake project using mcu
  • bluetooth and 16f877a of home automation project
  • PIC18 LED

The post parking management system project using pic microcontroller appeared first on PIC Microcontroller.

What is Led matrix? Types of Dot matrix display with working

$
0
0

What is LED matrix? Led matrix is a dot matrix of large display, low resolution value and is useful for both industrial or commercial displays as well as for hobbyist human interface machines. In contains a 2-D diode matrix which have the cathode joined in rows and anode in columns. In this LED matrix each can be control individually by controlling the electricity through each pair of columns or rows diodes. These matrix are very popular matrix by means of displaying information it, allows the static and animated images and text. A LED matrix is shown in figure.

What is Led matrix Types of Dot matrix display with working

Types of LED Matrix:

There are so many types are LED matric have been used for industrial and commercial purposes, some of which are discussing in this article with respect to structure.

  1. 8*8 dot Matrix
  2. 5*7 dot Matrix
  3. 128*16 Two lined
  4. 128*32 Four lined
  5. 128*64 Eight lined

8*8 dot Matrix:

In dot matrix multiple diodes are connecting together in rows and columns, this is done to minimize the number of pins required to drive the dot light emitting diodes. Suppose in 8*8 dot matrix there would be 64 I/O pins for displaying each

diode pixel

diode pixel. For making 8*8 dot matrix all the anodes are connecting together in rows R1 to R8, similarly the cathodes are connected together in columns C1 to C8, by doing this the required number of I/O pins have reduced by 16 shown is below:

According to the figure each LED is addressed to its row and column number. If R5 is pulled high and C4 pulled low, then the LED in fifth row and fourth column would be high, similarly the characteristics can also be displayed by scanning of each row and column.

5*7 dot Matrix:

A 5*7 LED matrix have 5 rows and 7 columns of light emitting dioses, which are connecting together for making this shown is figure in 3. According to the figure we want to display an alphabet word A then first we pulled high the column C1 and pulled low the other columns by blocking their ground paths. Now the C1 is pulled high and need to turn on the LEDs of rowsR2 to R7 of this column. This is done by the applying the forward bias voltage to these rows. Next select the column C2 and deselect the other column and apply the forward bias voltage across R1 and R5, and so on.

Construction of dot Matrix:

The construction of this display is very simple if you want to make your own prototype display then the diodes are just solder on Vero board or premade double or single sided board. Suppose we want a construct a prototype 8*8 dot matrix display shown in figure 2, then we have required 64 light emitting diodes. These diodes are solder on overboard or single sided board. The positive end of one diose is connected to other positive end of the diode for making the rows, similarly the 8 rows are made by connecting the positive end of each diode. The negative end one diode is connected to the negative end of other diode. For making the columns of this display, similarly the 8 columns are made by connecting the negative end of each diode. All these diodes are connected with each other through bare copper wire and all these are should be properly sold otherwise there would be no connection between all these.

Dot Matrix Interfacing with Microcontroller:

The dot matrix display consists of rows and columns, in these rows and columns LEDs are connecting. These can be on or off as wish, but this can be only done through microcontroller. Here we will interface pic microcontrollers with dot matrix display shown in figure.

Dot Matrix Interfacing with Microcontroller:

According to the figure we can see that, the microcontroller each port pin can directly drive each row or column of dot matrix display. For driving the column lines of dot matrix display the microcontroller requires additional circuit. The AT89S51 microcontroller is a high performance, low power CMOS 8-bit microcontroller which have 4k byte programmable flash memory. This device was manufactured by using Atmel s high density nonvolatile memory technology. This is compatible with the industry standard 80C51instruction.This microcontroller consist of 4 ports and 32 I/O lines. Here the dot matrix display rows are connected of port 1 and columns are connected to port 2. But columns are connected with extra IC ULN2003A.This is a high voltage (50V) high current (500mA per channel) with Darlington pair transistor array. This IC have seven channels with individually clamp output diodes. This is an active high device this means that the logic high must be applied at the input side for making the cross ponding output high. The input pins are shown with 1B,2B,3B,4B,5B,6B and 7B while the cross ponding pins are shown with 1C,2C,3C,4C,5C,6C and 7C. For displaying the alphabet,A proper code is required, which is burn in microcontroller for turn on and turn off the cross pondingLED

Read more: What is Led matrix? Types of Dot matrix display with working

Current Project / Post can also be found using:

  • pic16f84a projects as led

The post What is Led matrix? Types of Dot matrix display with working appeared first on PIC Microcontroller.

How to use input output ports 8051 microcontroller|LED blinking

$
0
0

How to use input output ports 8051 microcontroller. 8051 microcontroller has 40 pins comprising of four I/O ports. 8 pins are used for specific purposes and 32 pins are used as input/output pins to connect the microcontroller with the peripheral devices. Each of PORT is 8-bit, which can be configured as input or output port. In this article we will learn how to use I/O ports of 8051 microcontroller so that they can be used for read and write purpose. Before reading this article further you should know how to program 8051 microcontroller with Keil.

Page Contents

  • 1 PIN DIAGRAM of  input output ports 8051 microcontroller
  • 2 PORTS DESCRIPTION of  input output ports 8051 microcontroller
  • 3 PIN CONFIGURATION SETTINGS of input output ports 8051 microcontroller
  • 4 LED blinking with input output ports 8051 microcontroller
  • 5 PROTEUS SIMULATIONS of LED blinking with  input output ports 8051 microcontroller
  • 6 Video lecture on input output ports of 8051 microcontroller
  • 7 CODE of input output ports 8051 microcontroller

PIN DIAGRAM of  input output ports 8051 microcontroller

input-output-ports-of-8051-microcontroller

PORTS DESCRIPTION of  input output ports 8051 microcontroller

PORT 0:

P0 includes pins (32-39). It is an I/O port with some alternative functions.

  1. When the external memory is used with microcontroller, then the lower address byte (addresses A0-A7) is applied on P0. If not using external memory, all bits of P0 are configured for I/O purposes.
  2. P0doesn’t contain built-in pull-up resistor.
    • If any pin of this port is configured as an input, then it act as it “floats” and input has unlimited input resistance and undetermined potential.
    • When any pin of this port is configured as an output, it acts as an “open drain”. If logic 0 is given to port bit, the pin will be connected to ground (0V). If logic 1 is given to port bit, the external output will keep on “floating”. So, to apply logic 1 (5V) on this output pin, it is necessary to connect an external pull-up resistor.

PORT 1:

P1 includes pins (1-8). It is an I/O port with no alternative functions and configured only as general I/O purposes. P1 contains built-in pull-up resistor and is compatible with TTL circuits.

PORT 2:

P2 includes pins (21-28). It is an I/O port with alternative functions as port 0 except P1 when the external memory is used with microcontroller, then the higher address byte (addresses A8-A15) is applied on P2. When no external memory is used, all bits of P0 are configured as I/O purposes.

PORT 3:

P3 includes pins (10-17). It is an I/O port with different function. For using the alternative functions, a logic one (1) must be applied to appropriate bit of the P3 register. In hardware terms, this port is similar to P0 but it contains built-in pull-up resistor.

PIN CONFIGURATION SETTINGS of input output ports 8051 microcontroller

For input:        Pin is configured as 1 for input.

For output:      Pin is configured as 0 for output.

Current limitations:

  • When pin is are configured as an output, single pin can receive a current of 10mA.When pin is configured as input, then built-in pull-up resistors provide very weak current, but can handle up to 4 TTL inputs.
  • If a port’s all 8 bits are active, then the total current must be limited to 15mA. But for port 0, it can be up to 26mA (port P0: 26mA).
  • If all 4 ports (32 bits) are active, then the total current must be limited to 71mA.

LED blinking with input output ports 8051 microcontroller

In this example I will explain how to use I/O ports of 8051 microcontroller. Input to the microcontroller can be given through push button and output can be seen through LED. Firstly all the port pins are defined. Port 2 is used as output port and port 3 is used as input port.  These Ports are initialized with 0 (to write) and 1 (to read) logic respectively. Delay function is used to give the delay in showing output. Frequency of crystal should be set to 11.059MHz. Program is written in C language using “keil” software and hex file isloaded in the microcontroller.

WORKING of input output ports 8051 microcontroller:

When we run the simulation, if first push button is pressed, first led will glow. It will keep glowing for 1 second and then it goes off. When 2nd push button is pressed, 2nd led will glow. Any LED can be ON according to the respective input of the button. If we want to show the output for more time then delay call is passed large integer value.

PROTEUS SIMULATIONS of LED blinking with  input output ports 8051 microcontroller

LED-blinking-with-8051-microcontroller

Video lecture on input output ports of 8051 microcontroller

CODE of input output ports 8051 microcontroller

#include<reg51.h>
sbit Led1 = P2^0;          //Defining LED Pins

sbit Led2 = P2^1;

sbit Led3 = P2^2;

sbit Led4 = P2^3;

sbit Button1 = P3^0;      //Defining Button Pins

sbit Button2 = P3^1;

sbit Button3 = P3^2;

sbit Button4 = P3^3;

void Delay(int);     //Delay function declaration

int main ()

{

P2 = 0x00;                                          //used as output port

P3 = 0xFF;                                          //used as input port

do

{

if(Button1 == 0 )                               //If 1stswitch pressed

{

Led1 = 1;                                        //1st LED ON

Delay(1000);

Led1 = 0;                                        //LED OFF

}

if(Button2 == 0 )               //If 2ndswitch pressed

{

Led2 = 1;                                        //2nd LED ON

Delay(1000);

Led2 = 0;

}

if(Button3 == 0 )               //If 3rdswitch pressed

{

Led3 = 1; //LED ON                    //3rd LED ON

Delay(1000); //Delay

Led3 = 0; //LED OFF

}

if(Button4 == 0 )               //If 4thswitch pressed

{

Led4 = 1; //LED ON                    //4th LED ON

Delay(1000); //Delay

Led4 = 0; //LED OFF

}

}

while(1);

}

void Delay(int k)

{

int j;

inti;

for(i=0;i<k;i++)

{

for(j=0;j<100;j++)

{

}

}

}

Read more Information…

How to use input output ports 8051 microcontroller|LED blinking

Current Project / Post can also be found using:

  • PIC16F876A 8*8 matrix display
  • pic18 lightup led project

The post How to use input output ports 8051 microcontroller|LED blinking appeared first on PIC Microcontroller.

Viewing all 387 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>