Society of Robots - Robot Forum

Software => Software => Topic started by: junior000 on February 01, 2008, 01:42:20 PM

Title: programming ports (digital)
Post by: junior000 on February 01, 2008, 01:42:20 PM
hi, i am using p18f4550 and c18 compiler
  i configured all the analog ports as digital i/o
  then for the input 1 on port RE0 the led1 has to glow
  but the led1 is always in OFF state and led2 in ON state.
   can anyone tell what is wrong with the code??
   it got built in the compiler


#include<stdlib.h>
#include<p18f4550.h>
#include<delays.h>
#define sw1 PORTEbits.RE0
void main()
{
  ADCON1 = 0b00001111; //configuring all analog ports as digital i/o
  TRISC = 0b00111111;  //led1 and led2 as output
  TRISE = 0b11111111;  //all PORTE bits as digital input
  while(1)
   {
       if(sw1==1) //if portRE0==1 then switch on led1
       {
        PORTC = 0b10000000;
       }
       else if(sw1==0) //else switch on led2
       {
       PORTC = 0b01000000;
       }
       
   }
}
Title: Re: help!
Post by: hazzer123 on February 01, 2008, 03:22:06 PM
Try using LATC instead of PORTC.
Title: Re: help!
Post by: SmAsH on February 02, 2008, 12:11:50 AM
also the title is not very helpful http://www.societyofrobots.com/robotforum/index.php?topic=1480.0
Title: Re: help!
Post by: ed1380 on February 02, 2008, 12:31:17 AM
also the title is not very helpful http://www.societyofrobots.com/robotforum/index.php?topic=1480.0
neither is your spam. http://www.societyofrobots.com/robotforum/index.php?topic=3038.msg22522#msg22522

this is not really that good
(http://i43.photobucket.com/albums/e398/RussianCommy/untitled-55.jpg)
Title: Re: help!
Post by: SmAsH on February 02, 2008, 04:07:24 AM
oh damnn i got bad burn :o sorry i couldnt resist doing this.