Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Learning PIC Programming

Status
Not open for further replies.
Hey,I have made the sensor circuit using IR transmitters and photocells and LM358N !! However the LEDs blink only while varying the voltage with potentiometer and are not affected by black or white surface ! The circuit is right ! What may be the problem ?? Please help as I need it urgently for a competition ! Please !
 

Hello,I got through the above problem !!
However,I have written the following program for the Line Tracer,but I am not getting any output at the output terminals !!
Please Help as soon as possible !!

Code:
void main() 
{
  TRISB=0b00000000;
  TRISA=0b11111111;
  while(1)
  {
   if(PORTA == 0b00000101)
    PORTB=0b00001010;
   if(PORTA == 0b00000111)
    PORTB=0b00000101;
   if(PORTA == 0b00000100)
    PORTB=0b00001000;
   if(PORTA == 0b00000001)
    PORTB=0b00000010;
   if(PORTA == 0b00000000)
    PORTB=0b00000000;
   
  }
}

Please help !! I am in a fix and the competition is in coming two days !
 

Hi,
This should be your basic hardware diagram:
70_1290615956.png


This is the link to the compiler I recommend - mikroC:
mikroC PRO for PIC - C compiler for PIC microcontroller - mikroElektronika

This is the link to a free ebook on using mikroC for programming PICs:
PIC Microcontrollers - Programming in C - Free Online Book - mikroElektronika

This is a sample program using the given hardware in mikroC:
Code:
void main(void){
   PORTB = 0; //Removes initial value that PIC holds in PORTB
   TRISB = 0; //This tells the PIC that PORTB should be output
   do{
      PORTB = 255; //255 = 11111111 in binary, so all LED's connected to PORTB glow
      delay_ms(500); //Wait for 500ms
      PORTB = 0; //Turn all LEDs off
      delay_ms(500); //Wait for 500ms
   }while(1); //Continuously do this
}

Go to the "Project" Menu. From the drop-down menu, select "Edit Project". Click "Default".

That book should get you going in using mikroC and PICs in no time.

Hope this helps.
Tahmid.

Hi Tahmid,

Can you convert this to a MPLAB IDE C Language program? Thanks
 

Hey,Im done with the above problem !! PortA is analog,so I changed it to C and now its working !
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top