Académique Documents
Professionnel Documents
Culture Documents
pinMode(ledPin,OUTPUT);//|]IO [|[OUTPUT
]
void loop()
unsigned char j;
for(j1;j<6;j++)//]200ms ]1~6 ]|(led )
digitalWrite(j,HIGH);//j ]|(led )
delay(200);//}200ms
]
for(j6;j>1;j--)//]200ms ]6~1 ]|(led )
digitalWrite(j,LOW);//j ]|(led )
delay(200);//}200ms
]
]
//)])|[
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
void flash(void)
unsigned char i;
for(i1;i<6;i++)//]1~6 ^\]|
pinMode(i,OUTPUT);//i ^]|
]
void loop()
style_1();//|1
flash();//])
style_2();//|2
flash();//])
style_3();//|3
flash();//])
]
In this Experiment, you can learn the ' Ior statements
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
The Code :
for(i1;i<6;i++)// Set the digital IO pins(1, 2, 3, 4, 5, 6) configured as ~OUTPUT
pinMode(i,OUTPUT);// Set the digital pins(i) configured as ~OUTPUT
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 2 : buzzer Speaker.
1. What is an buzzer?
Features:
1) High sound pressure with low power consumption
2) Compact, lightweight
3) No-contact design makes element highly reliable and eliminates noise problem
4) Easily mountable
5) A wide variety oI tones can be generated depending on casing design
Applications:
1) Telephone ringers
2) ConIirmation tones in various oIIice automation equipment
3) Used in a variety oI consumer products such as microwave ovens and reIrigerators
4) Clocks, toys games
5) Automobiles
In this experiment, because oI the internal buzzer with a drive circuit, it can be used directly.
Prepare: 1 X buzzer Speaker , some Jumper cable.
To build the circuit, attach buzzer to digital IO pin 7 . Connect the cathode (the shorter,
negative leg) directly to ground.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Code : open the Iolder buzzer, and open the buzzer.pde
In this program, you will hear the Ambulance siren.
int buzzer7;//|jj,[]IO ]
void setup()
pinMode(buzzer,OUTPUT);//|]IO ]|[OUTPUT
]
void loop()
pinMode(key,OUTPUT);//|]IO ]|[
]
void loop()
int i;//
while(1)
ianalogRead(1);//,]||1 j
if(i>512)//;j,512l0.25V
digitalWrite(key,HIGH);//|]])led )
else
digitalWrite(key,LOW);//|]],led )
]
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 4 : preemptive response device
1. Do a funny project.
Experiment:
Prepare: 3 X key, 1 X buzzer , 1 X red LED , ! X green LED . 2 X 220-ohm resistor ,
some Jumper cable.
To build the circuit, attach each key`s pin 1 to the 5 Volt supply, pin 2 to the board`s Analog
Pin 1 (key 1), pin 2 (key 2), pin 3 (key 3).
The LED attach to Digital pin 8 (red LED), pin 7 (green LED) through 220-ohm resistor.
The buzzer connect to Digital pin 5.
Code : open the Iolder KBL , and open the KBL.pde
int RedLed8;///]|-)
int GreenLed7;//]|,)
int i;//i
int j0;//j
void buzzer()//,j),|]
for(i0;i<80;i++)
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
digitalWrite(5,HIGH);//),
delay(1);//}1ms
digitalWrite(5,LOW);//),
delay(1);//}ms
]
]
void key_scan()//|j|||]
int key_1,key_2,key_3;//
key_1analogRead(1);//,]||][j
key_2analogRead(2);//,]||][j
key_3analogRead(3);//,]||][j
if(key_1<204&&key_2<204&&key_3<204)//;,|jj, 204l||j[ 1V
)}||j|
return;//7]
]
if(key_1>818)//;|j1 [j,,818l||j[4V)}|j1 |
delay(10);//j||]}100ms |])}
if(key_1>818)//;|j1 [j,,818l||j[4V)}|j1 ]
|
buzzer();//,),
digitalWrite(RedLed,HIGH);//-)
digitalWrite(GreenLed,LOW);//,),
]
else //||]]
return;//7]
]
]
if(key_2>818)//;|j2 [j,,818l||j[4V)}|j2 |
delay(10);//j||]}100ms |])}
if(key_2>818)//;|j2 [j,,818l||j[4V)}|j2 ]
|
buzzer();//,),
digitalWrite(RedLed,LOW);//-),
digitalWrite(GreenLed,HIGH);//,)
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
]
else //||]]
return;//7]
]
]
if(key_3>818)//;|j3 [j,,818l||j[4V)}|j3 |
delay(10);//j||]}100ms |])}
if(key_3>818)//;|j3 [j,,818l||j[4V)}|j3 ]
|
buzzer();//,),
digitalWrite(RedLed,LOW);//-),
digitalWrite(GreenLed,LOW);//,),
]
else //||]]
return;//7]
]
]
]
void setup()
for(i5;i<8;i++)
pinMode(i,OUTPUT);//|5~8 ]||[
]
]
void loop()
while(1)
key_scan();//j'|||j
]
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 5 : 7seg-4digit LED Display
1. What is an 7seg-4digit LED Display?
In the Iollowing picture, there are other LED displays.
The internal structure OI LED display. This is the Common cathode 7seg-4digit LED
Display that we will use in this Experiment.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
First Experiment:
Prepare: 1 X 7seg-4digit LED Display , 8 X 220-ohm resistor , some Jumper
cable.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
To build the circuit, attach the LED display`s (through a 220-ohm resistor) Pin 11, 7, 4, 2, 1,
10, 5, 3 to your Arduino board`s digital Pin 12, 11, 10, 9, 8, 7, 6, 5 .
Attach the LED display`s 12, 9, 8, 6 to the Ardiuno board`s digital Pin 4, 3, 2, 1 .
Code : open the Iolder digitaltube1 , and open the digitaltube1.pde
In the program, It will loop to show the number Irom 0 to 9
//|jj,|[]IO ]
int a 12;
int b 11;
int c 10;
int d 9;
int e 8;
int f 7;
int g 6;
int dp 5;
int ls1 1; //|({](
int ls2 2; //{](
int ls3 3; //{](
int ls4 4; //|{](
//]0 , 11111100
void digital_0(void)
unsigned char j;
digitalWrite(dp,LOW);//]5 ]],])DP |
digitalWrite(g,LOW);//,g |
for(j7;j<12;j++)//))_|
digitalWrite(j,HIGH);
]
//]1 , 01100000
void digital_1(void)
unsigned char j;
digitalWrite(a,LOW);
for(j5;j<9;j++)
digitalWrite(j,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
]
//]2
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
void digital_2(void)
unsigned char j;
digitalWrite(c,LOW);
digitalWrite(f,LOW);
digitalWrite(dp,LOW);
for(j11;j<12;j++)
digitalWrite(j,HIGH);
for(j8;j<9;j++)
digitalWrite(j,HIGH);
digitalWrite(g,HIGH);
]
//]3 22
void digital_3(void)
unsigned char j;
digitalWrite(e,LOW);
digitalWrite(f,LOW);
digitalWrite(dp,LOW);
for(j9;j<13;j++)
digitalWrite(j,HIGH);
digitalWrite(g,HIGH);
]
//]4
void digital_4(void)
digitalWrite(a,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(dp,LOW);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
]
//]5
void digital_5(void)
unsigned char j;
digitalWrite(b,LOW);
digitalWrite(e,LOW);
digitalWrite(dp,LOW);
digitalWrite(a,HIGH);
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
for(j6;j<7;j++)
digitalWrite(j,HIGH);
for(j9;j<10;j++)
digitalWrite(j,HIGH);
]
//]6
void digital_6(void)
unsigned char j;
digitalWrite(b,LOW);
digitalWrite(dp,LOW);
digitalWrite(a,HIGH);
for(j6;j<10;j++)
digitalWrite(j,HIGH);
]
//]7
void digital_7(void)
unsigned char j;
for(j5;j<9;j++)
digitalWrite(j,LOW);
for(j10;j<12;j++)
digitalWrite(j,HIGH);
]
//]8
void digital_8(void)
unsigned char j;
digitalWrite(dp,LOW);
for(j6;j<12;j++)
digitalWrite(j,HIGH);
]
//]9
void digital_9(void)
unsigned char j;
digitalWrite(e,LOW);
digitalWrite(dp,LOW);
for(j9;j<12;j++)
digitalWrite(j,HIGH);
for(j6;j<7;j++)
digitalWrite(j,HIGH);
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
]
//----------------------------
void Display(unsigned char mun)
switch (mun)
case 0:
digital_0();//]0
break;
case 1:
digital_1();
break;
case 2:
digital_2();
break;
case 3:
digital_3();
break;
case 4:
digital_4();
break;
case 5:
digital_5();
break;
case 6:
digital_6();
break;
case 7:
digital_7();
break;
case 8:
digital_8();
break;
case 9:
digital_9();
break;
default: return;
// if nothing else matches, do the default
// default is optional
]
]
void setup()
unsigned char i, j, t;
while(1)
t 1;
for(j0; j<4 ; j++)
digitalWrite(ls1,LOW); //,](|[
]
for(i0; i<9 ; i++)
if(t1) //{](]
digitalWrite(ls4,HIGH);
digitalWrite(ls3,HIGH);
digitalWrite(ls2,HIGH);
digitalWrite(ls1,LOW);
]
if(t2) //{](]
digitalWrite(ls4,HIGH);
digitalWrite(ls3,HIGH);
digitalWrite(ls1,HIGH);
digitalWrite(ls2,LOW);
]
if(t3) //{](]
digitalWrite(ls4,HIGH);
digitalWrite(ls2,HIGH);
digitalWrite(ls1,HIGH);
digitalWrite(ls3,LOW);
]
if(t4) //|{](]
t 0;
digitalWrite(ls3,HIGH);
digitalWrite(ls2,HIGH);
digitalWrite(ls1,HIGH);
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
digitalWrite(ls4,LOW);
]
Display(i);
delay(2000);//}2s
t++;
for(j0; j<4 ; j++)
digitalWrite(ls1,LOW); //,](|[
]
]
]
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 6 : Tilt Switch
1. What is an Tilt Switch?
Tilt Switch, you can call it Shaking Switch or Position Switch .
Usually we can easy to buy these style oI tilt switch : SW-200D.SW-460.SW-300DA and
so on.
In the experiment , we use SW-200D . SW-200D as the ball type single-directional tilt sensor
trigger switch..
the product when the wizard power side (silver pin side A) tilt angle is greater than 15 degrees,
in order to open OFF state, when the product is tilted to change the level oI the state, the trigger
terminal (gold-plated pin terminal C) below the level oI angle greater than 15 degree angle, Ior the
closed-circuit ON state. Horizontal, the swaying can be easily triggered. The silver pin down,
the shaking is not easy trigger.
First Experiment:
Prepare: 1 X Tilt Switch , 1 X LED , 1 X 220-ohm resistor , some Jumper cable.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
To build the circuit, grab an LED and attach its long, positive leg (called the anode) to pin 8
through a 220-ohm resistor . Connect the cathode (the shorter, negative leg) directly to ground.
Attach the Tilt Switch`s silver pin to the 5 volt supply, the other side to Analog Pin 5 .
Code : open the Iolder sketchjun04d , and open the sketchjun04d.pde
In the program, when we press the button, the led will light. Otherway, it will turn oII.
void setup()
pinMode(8,OUTPUT);//|]8 ]|[
]
void loop()
int i;//i
while(1)
ianalogRead(5);//,]||5 j
if(i>200)//;,5122.5V
digitalWrite(8,HIGH);//)led )
]
else//|
digitalWrite(8,LOW);//,led )
]
]
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 7 : Ambient Light sensor
1. What is an Ambient Light sensor ?
In the light intensity is strong , it`s resistance decreases; however , when the light is weak, this
sensor`s resistance increases.
First Experiment:
Prepare: 1 XAmbient Light sensor , 1 X buzzer , some Jumper cable.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
To build the circuit, attach buzzer`s long, positive leg (called the anode) to pin 6 through a
Ambient Light sensor . Connect the cathode (the shorter, negative leg) directly to ground.
Attach the Tilt Switch`s silver pin to the 5 volt supply, the other side to Analog Pin 5 .
Code : open the Iolder sketchjun17b , and open the sketchjun17b.pde
In the program, when the Light is stronger, the resistance oI sensor will be smaller, and
then the buzzer speak louder.
void setup()
pinMode(6,OUTPUT);
]
void loop()
while(1)
char i,j;
while(1)
for(i0;i<80;i++) //[[),
digitalWrite(6,HIGH);
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
delay(1);
digitalWrite(6,LOW);
delay(1);
]
for(i0;i<100;i++) //,[[),
digitalWrite(6,HIGH);
delay(2);
digitalWrite(6,LOW);
delay(2);
]
]
]
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 8 : 1602 LCD
1. What is 1602 LCD?
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
First Experiment:
Prepare: 1 X LCD Screen , 1 X 10k Potentiometer , some Jumper cable.
To build the circuit, To wire your LED screen to your Arduino, connect the Iollowing pins:
lCD lS ,u o d_u' ,u !?
lCD luu|' ,u o d_u' ,u !!
lCD D1 ,u o d_u' ,u
lCD D ,u o d_u' ,u 1
lCD Db ,u o d_u' ,u 3
lCD D ,u o d_u' ,u ?
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
/ddouu''y, u !0l ,o o \ uud 0\D, | ': , ou,u) o lCD :cu':
\O ,u ,u3).
Code : open the Iolder lcd1602 , and open the lcd1602.pde
/`
` The circuit:
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
` LCD RS pin to digital pin 12
` LCD Enable pin to digital pin 11
` LCD D4 pin to digital pin 5
` LCD D5 pin to digital pin 4
` LCD D6 pin to digital pin 3
` LCD D7 pin to digital pin 2
` 10K resistor:
` ends to +5V and ground
` wiper to LCD VO pin (pin 3)
`/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
]
void loop()
lcd.setCursor(0,0); // ||/
lcd.print("OK: ");
lcd.setCursor(5,0); // ||/
lcd.print("Arduino!");
lcd.setCursor(0,1); // ||/
lcd.print("Yes,B2CQSHOP");
delay(500);
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 9 : LM35 Temperature Sensor
1. What is LM35 Temperature Sensor ?
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage
is linearly proportional to the Celsius (Centigrade) temperature.
Connection Diagrams
Calibrated directly in Celsius (Centigrade) , Linear 10.0 mV/C scale Iactor
First Experiment:
Prepare: 1 X LM35 Temperature Sensor , 1 X 1602 LCD display , some Jumper cable.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Please check the Lesson 8 : 1602 LCD , to wire your LED screen to your Arduino .
Attach the LM35`s Pin Vout ( the middle pin) to your arduino`s /uu'o_ lu 0 . \cc o
v , 0ud o you uduuo |oud`: _ud
Code : open the Iolder sketchjun17b , and open the sketchjun17b.pde
In the program, when the Light is stronger, the resistance oI sensor will be smaller, and
then the buzzer speak louder.
/`
The circuit:
` LCD RS pin to digital pin 12
` LCD Enable pin to digital pin 11
` LCD D4 pin to digital pin 5
` LCD D5 pin to digital pin 4
` LCD D6 pin to digital pin 3
` LCD D7 pin to digital pin 2
` 10K resistor:
` ends to +5V and ground
` wiper to LCD VO pin (pin 3)
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
`/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//tempeter
int val;
int dat;
void setup()
Serial.begin(9600);
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
]
void loop()
valanalogRead(0);
dat(125`val)>>8; //,,[j
lcd.setCursor(0,0);
lcd.print("Tep: ");
lcd.setCursor(6,0);
lcd.print(dat);
lcd.setCursor(10,0);
lcd.print("'C");
delay(10);
lcd.setCursor(0,1);
if(dat>18)
lcd.print("Warm! B2CQSHOP");
]
else
lcd.print("Cold! B2CQSHOP");
]
delay(500);
]
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Lesson 10 : Infrared Remote Control
1. What is Infrared Receiver (IRM3638) ?
To know more about how to control IR Remote Control. You should have a knowledge oI the
\lC looco'
\lC looco' luu: : ( |,:.:|,o_c:.comkuo'd_uc.|m )
8 | udd:: uud 8 | commuud 'u_|
/dd:: uud commuud u uu:md c o 'u|'y
lu': d:uuc modu'uou
Cu uucy o 38k|z
b m o !.!?m: o ?.?m:
Hodu'uou:
T| \lC ,ooco' u:: ,u': d:uuc ucodu_ o | |:. luc| ,u':
: u b0: 'ou_ 38k|z cu |u: u|ou ?! cyc':). / 'o_cu' ! uk:
?.?m: o uu:m, |' u 'o_cu' 0 : ou'y |u' o |u, |u_ !.!?m:.
T| commudd cu duycyc' : !1 o !3.
Protocol :
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
The picture above shows a pulse train oI the NEC protocol. With this protocol the LSB is
transmitted Iirst. In this case Address $59 and Command $16 is transmitted. A message is started
by a 9ms AGC burst, which was used to set the gain oI the earlier IR receivers. This AGC burst is
then Iollowed by a 4.5ms space, which is then Iollowed by the Address and Command. Address
and Command are transmitted twice. The second time all bits are inverted and can be used Ior
veriIication oI the received message. The total transmission time is constant because every bit is
repeated with its inverted length. II you're not interested in this reliability you can ignore the
inverted values, or you can expand the Address and Command to 16 bits each!
A command is transmitted only once, even when the key on the remote control remains
pressed. Every 110ms a repeat code is transmitted Ior as long as the key remains down. This
repeat code is simply a 9ms AGC pulse Iollowed by a 2.25ms space and a 560s burst.
In this Experiment, we will use a little diIIerent IR Remote Control , which use WD6122
chip . ( Extended NEC protocol )
Pay attention: When there is no infrared signals, the receiver`s output is High ; while,
it receives an signal, its output is LOW . We can check the received pulse through the
Oscilloscope, analyse the program according to the waveform.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
The Command Values oI the IR Remote Control`s key like the Iollowing picture.
First Experiment:
Prepare: 1 X InIrared Receiver (IRM3638) , 1 X IR Remote Control , 1 X 10 kO
Resistors , some Jumper cable.
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
Please check the Lesson 8 : 1602 LCD , to wire your LED screen to your Arduino .
Attach the InIrared Receiver`s Pin Vout to your arduino`s digital Pin 8 , Please check the
Iollowing picture.
Code : open the Iolder IR , and open the IR.pde
In the program, when you press the key oI the IR Remote Control, the 1602 LCD will show
the commond value oI the key.
#include LiquidCrystal.h~
#deIine IRIN 8 //-(||
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int PulseWidth0;//]]
int ircode0x00;// j),(j
char adrLcode0x00;//((
char adrHcode0x00;//(((
void timer1init(void)//},|/]
TCCR1A 0X00;
TCCR1B 0X05;//},})
TCCR1C 0X00;
TCNT1 0X00;
TIMSK1 0X00; //)},('}
}
void remotedeal(void)//||(;]
//]|
lcd.clear(); //
delay(1);
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
lcd.setCursor(0,0);
lcd.print(ircode,HEX);//16 j
lcd.setCursor(0,1);
lcd.print(adrLcode,HEX);//16 j
}
char logicvalue()//)})j0T1]
TCNT1 0X00;
while(!(digitalRead(8))); //]|
PulseWidthTCNT1;
TCNT10;
iI(PulseWidth~7&&PulseWidth10)//]560us
while(digitalRead(8));//]|
PulseWidthTCNT1;
TCNT10;
iI(PulseWidth~7&&PulseWidth10)//|(]560us
return 0;
else iI(PulseWidth~25&&PulseWidth27) //|(]1.7ms
return 1;
}
return -1;
}
void pulsedeal()//||j;(T((],]
int i;
int j;
ircode0x00;//
adrLcode0x00;//
adrHcode0x00;//
//|jj,,('[j),(j
Ior(i 0 ; i 16; i)
iI(logicvalue() 1) //1
ircode , (1i);//]jj
}
//|jj,,('[((
Ior(i 0 ; i 8; i)
iI(logicvalue() 1) //1
adrLcode , (1i);//]jj
}
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
//|jj,,('[(((
Ior(j 0 ; j 8; j)
iI(logicvalue() 1) //1
adrHcode , (1j);//]jj
}
}
void remotedecode(void)//(]
TCNT10X00;
while(digitalRead(8))//]|
iI(TCNT1~1563) //]|}[100ms]}||j|
ircode0x00II;// j),(j
adrLcode0x00;//j(jj
adrHcode0x00;//j()j
return;
}
}
//;]|}[100ms
TCNT10X00;
while(!(digitalRead(8))); //]|
PulseWidthTCNT1;
TCNT10;
iI(PulseWidth~140&&PulseWidth141)//9ms
while(digitalRead(8));//]|
PulseWidthTCNT1;
TCNT10;
iI(PulseWidth~68&&PulseWidth72)//4.5ms
pulsedeal();
return;
}
else iI(PulseWidth~34&&PulseWidth36)//2.25ms
while(!(digitalRead(8)));//]|
PulseWidthTCNT1;
TCNT10;
iI(PulseWidth~7&&PulseWidth10)//560us
www.bestqshop.com Ebay store: b2cqshop , E-qstore
www.bestqshop.com Ebay store: b2cqshop , E-qstore
return;
}
}
}
}
void
setup()
unsigned char i;
pinMode(IRIN,INPUT);//|-(||]
lcd.begin(16, 2);
}
void loop()
timer1init();//},|/
while(1)
remotedecode(); //(
remotedeal(); //||(;
}
}