Friday, November 18, 2011

Pin It


Get Gadget

8*6 LED Matrix for Intelligent Traffic Light System

Next Task was to make the controlling mechanism for traffic lights. Major problem was, there are not enough I/O pins in the PIC to control each bulb of the traffic light. So we choose small mechanism to avoid that problem. That is the 8*6 LED Matrix. To explain this concept I will use a article publish by electronic department of our university. (http://www.ent.mrt.ac.lk/web/knowledgebase/uc/5.3.pdf) . Here we use the mechanism used to light up pixels in a LCD display. I will explain the steps to light up all the 40 LEDs using this mechanism at same time.

     
  • To light a single LED in this matrix we have to give +,- voltages to its pins. You can notice that if we set any pin in PORTB to logic 1, it will give + voltage to LED's + pin. 
  • Then How we can give the ground connection to the - pin of the LED. For that we have to turn on the D400 transistor for that particular column.
  • After that particular LED will be light up. For example we can use this code to light up all the LEDS RA0 column,
          PORTB=0b11111111;
          PORTA=0b00000001;
  • To light up all the LEDS RA1 column,
          PORTB=0b11111111;
          PORTA=0b00000010;
  • To light up all the LEDS RA2 column,
          PORTB=0b11111111;
          PORTA=0b00000100;
  • To light up all the LEDS RA3 column,
          PORTB=0b11111111;
          PORTA=0b00001000;
  • To light up all the LEDS RA4 column,
          PORTB=0b11111111;
          PORTA=0b00010000;
  • To light each other LED in RA0 Column you can use this code,
          PORTB=0b10101010;
          PORTA=0b00000001;
  • Like that we can control each LED in a column using PORTB pins.But you can identify that you cant light up RA0 columns 0the row LED and off the   RA1 columns 0the row LED at the same time. Because we use PORTA pins to choose the column and PORTB to choose the row.
  • So how can we light up all the columns at same time. We use the weakness of human eye to this.If we light different columns at high speed you cant see a difference you will notice that all the LEDs are lighting at the same time.
  • Here is the code for that,
    while(1){
          PORTB=0b10101010;
          PORTA=0b00000001;
          PORTB=0b10101010;
          PORTA=0b00000010;
          PORTB=0b10101010;
          PORTA=0b00000100;
          PORTB=0b10101010;
          PORTA=0b00001000;
          PORTB=0b10101010;
          PORTA=0b00010000;
    }
  • In the same mechanism we implement the control system for our traffic light system. Below diagram will show you how we implement that.

    No comments:

    Post a Comment