336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

int s0=3,s1=4,s2=5,s3=6;

int out=2;

int flag=0;

byte counter=0;

byte countR=0,countG=0,countB=0;

void setup()

{

Serial.begin(115200);

pinMode(s0,OUTPUT);

pinMode(s1,OUTPUT); 

pinMode(s2,OUTPUT);

pinMode(s3,OUTPUT); 

}


void TCS()

{

flag=0;  

digitalWrite(s1,HIGH);

digitalWrite(s0,HIGH);

digitalWrite(s2,LOW);

digitalWrite(s3,LOW);

attachInterrupt(0, ISR_INTO, CHANGE);

timer0_init();

}


void ISR_INTO()

{

counter++;

}


void timer0_init(void)

{

TCCR2A=0x00;

TCCR2B=0x07;   //the clock frequency source 1024 points

TCNT2= 100;    //10 ms overflow again

TIMSK2 = 0x01; //allow interrupt

}


int i=0;

ISR(TIMER2_OVF_vect)//the timer 2, 10ms interrupt overflow again. Internal overflow interrupt executive function

{

TCNT2=100;

flag++;

if(flag==1)

{

countR=counter;

Serial.print("red=");

Serial.println(countR,DEC);

digitalWrite(s2,HIGH);

digitalWrite(s3,HIGH);

}


else if(flag==2)

{

countG=counter;

Serial.print("green=");

Serial.println(countG,DEC);

digitalWrite(s2,LOW);

digitalWrite(s3,HIGH);

}


else if(flag==3)

{

countB=counter;

Serial.print("blue=");

Serial.println(countB,DEC);

Serial.println("\n"); 

digitalWrite(s2,LOW);

digitalWrite(s3,LOW);

}

else if(flag==4)

{

flag=0;

}

counter=0;

}


void loop()

{

TCS();

while(1);

}

Posted by ElectricShock
:
BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
Programming(=프로그래밍) (3)
MiDi (2)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백