 Re: How to make an LED gradually and slowly get brighter and dimmer?
 Re: How to make an LED gradually and slowly get brighter and dimmer?
		
		
				
				
		
			
				
					
	
		
			
			
				The first problem is that I'm using a 16F886 and I can't seem to get this code to work with it.  I've done some reconfiguring, and PBP will compile it for the 16F886, but I get an error message when I actually try to program the chip, so I'm clearly not doing something correctly.
			
		
 
	 
 firstly there is not much point reposting my code , you need to post what you are using , my example is for a pic16f1825 
for a 16f886  things will be different 
osc is different,   ccp1 and 2 pins are different , ansel settings are different,  config word is different tris ..........
	
		
			
			
				 Also, I really don't fully understand what is going on.  I understand what the code is doing, but I don't understand the CCP module well enough to understand what setpwm is doing.  Although the line "while pl" doesn't make any sense to me.  Doesn't there need to be some sort of statement like "while pl < 99"?
			
		
 
	 
 in nearly all computer languages  false=0  anything else is true
so   "while pl"   means  while pl is true   ie  anything but 0 
	
		
			
			
				 CCPR1L = PW>>2;
 ccp1con=12|((PW&3)<<4);     led2
 CCPR2L = Pl2>>2;            led1 
 ccp2con=12|((Pl2&3)<<4);
			
		
 
	 
 10 bit pwm   is   high 8 bits =CPRxL   , LOW 2 bits = CCPxCON  bits 4,5
so our 10 bit pwm value "PW"   is deconstructed   CCPR1L = PW>>2 moves high 8 bits into CCPR1L
and with [ccp1con=12|((PW&3)<<4)]   the low two bits  "PW&3"    are shifted to   bit 4,5 posn and or(ed)   into   ccp1con
				
			 
			
		 
			
                        	
		        
			
			Warning I'm not a teacher
			
			
		 
	
Bookmarks