กดปุ่มBUTTONในAVRSTUDIO
20/6/2558 SONGCHAI PRAPATRUNGSEE
กดปุ่มBUTTONในAVRSTUDIO
SOURCE CODE
/*
* AT.c
*
* Created:
20/6/2558 18:06:48
* Author: sc
*/
#include <avr/io.h>//REGISTER OF AVR
#define F_CPU 8000000//DEFINE CLOCK SPEED
#include <util/delay.h>//FOR DELAY
#define POWER_B (PINB&0X80)
int main(void)
{
DDRA=255;//DDRX
1=OUTPUT,O=INPUT
DDRB=0;//0=INPUT ALL PORTB
PORTB=255;
while(1)//LOOP
FOREVER
{
if (POWER_B==0)
{
PORTA=0XF0;
_delay_ms(1000);//Millisec
PORTA=0X0F;
_delay_ms(1000);
PORTA=0XF0;
_delay_ms(1000);
PORTA=0X0F;
_delay_ms(1000);
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น