EM Systems

EM Systems Electrical Electronics and Bio medical Company providing present and Future solutions to your Problems !!!!!!!!!!!

We Deal in industrial Automation, Industrial project and Final year projects . We also offer Bio Medical services and Embedded systems Services .

18/04/2014

Honda’s solar powered EV charging station

18/04/2014
AVR Tutorial - C Language-We use AVR Butterfly and AVR StudioYou might wonder why blinking an LED is the first project, ...
18/04/2014

AVR Tutorial - C Language-

We use AVR Butterfly and AVR Studio

You might wonder why blinking an LED is the first project, when traditional C programming texts start with the classic “Hello, world” program. It certainly seems that since the Butterfly has an LCD that can show the words it would be easy. But the reality is that controlling the LCD is much more complex than linking an LED, so we’ll save the LCD for later when we’ve gotten a better handle on things.
Find Programmers Notepad that was installed as part of WinAVR (you should have an icon for it on your desktop) and open it. You will need to add a tool, which will let you use the AVR Studio simulator.

the Code :
//blinking.c




int main (void)
{
//set PortD for Output
DDRD =0xFF;
while(1)
{
for(int i=1;i1;i-=i/2)
{
PORTD=i;
_delay_loop_2(30000);
}
}
return 1;
}

Switch-LED program IN C-programming language for PIC18F4520 microcontroller Components needed:    PIC18F4520 MICROCONTRO...
18/04/2014

Switch-LED program IN C-programming language for PIC18F4520 microcontroller
Components needed:

PIC18F4520 MICROCONTROLLER DEVELOPMENT BOARD
LED
RESISTER
POWER SUPPLY – 5V



SCHEMETIC

switch-led

Schematic description:

The brain of the system is Pic18f4520 microcontroller. Resistor is used to limit the current flow. Led is attached to pinRB4 of PORTB. Switch is connected to pinRC4 of PORTC. The whole system is powered by 5V power supply.

Programming :
// LED FLASH Example // Port B Pin RB4 is used to Flash LED config OSC = HS config LVP = OFF

config WDT = OFF

config DEBUG = OFF



// Header files







//main program starts from here

void main ()



{

/* NOTE: There are some pins set as analogue, so in order to use these pins

as digital you need to convert them to digital */

TRISC = 0xff; // Make PORTC as input

TRISB = 0×00; // Make PortB as output



while(1) // loop forever

{

if(PORTCbits.RC4 ==1) //If button pressed execute remaining code

{

PORTBbits.RB4 = 0×00; // LED OFF

Delay10KTCYx(200); //short delay here

PORTBbits.RB4 = 0xff; // LED ON

Delay10KTCYx(200); //short delay here

}

}

}



Implementation:

Once the program is successfully executed in MPLab IDE, the only thing you need a programmer (e.g. ICD2) to program the device.

Result:

The LED connected to pinRB4 of PORTB keep on flashing at an interval of 800ms, if Switch is pressed else do nothing.

Address

D. A. V College Road
Rwp
48000

Alerts

Be the first to know and let us send you an email when EM Systems posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Practice

Send a message to EM Systems:

Share

Share on Facebook Share on Twitter Share on LinkedIn
Share on Pinterest Share on Reddit Share via Email
Share on WhatsApp Share on Instagram Share on Telegram