Issues with Common Anode RGB-LED Project

Discussion in 'Embedded Systems and Microcontrollers' started by pleditor, Feb 19, 2013.

  1. pleditor

    Thread Starter New Member

    Feb 19, 2013
    4
    0
    I am completely new to Microcontrollers and Electronics, however a made some progress and just got stuck at the point where i want to turn on all LED's Red color with the "PORTX.FX" command (led 1,3,5,7 stays black). If i try to turn on all Red LED's separately it will work with no problems. Here's the Code:

    Code ( (Unknown Language)):
    1. void main()
    2. {
    3.  
    4.      TRISA = 0b000000;
    5.      TRISB = 0b000000;
    6.      TRISC = 0b000000;
    7.      TRISD = 0b000000;
    8.  
    9.      PORTA = 0b111111;
    10.      PORTB = 0b111111;
    11.      PORTC = 0b111111;
    12.      PORTD = 0b111111;
    13.  
    14.      ANSEL = 0b000000;
    15.      ANSELH = 0;
    16.  
    17.  
    18.   PORTA.F2 = 0;
    19.   PORTA.F5 = 0;
    20.   PORTB.F2 = 0;
    21.   PORTB.F5 = 0;
    22.   PORTC.F2 = 0;
    23.   PORTC.F5 = 0;
    24.   PORTD.F2 = 0;
    25.   PORTD.F5 = 0;
    26.  
    27. }
    I am using MikroC compiler, with a PICkit 2. I appreciate every help here ;-).
     
  2. rstevenson

    New Member

    Apr 5, 2011
    21
    1
    I havent looked at the code, but you need current limiting resistors in series with your Leds. Also, Im curious as to why you are using Vpp to power the leds?
     
  3. pleditor

    Thread Starter New Member

    Feb 19, 2013
    4
    0
    The schematics is wrong the cathode of the LED's should be on VSS. However after replacing the wrong resistors with the right ones everything works as wanted :)

    problem solved, thanks ;-)
     
Loading...