T
teongkia
Guest
Bok Imam ovaj kod.JA pokušao Internet vanjska strana na mikrokontroler, ali nije 'funkcionirati.Ja sam trenutno vlasništvo projekt automobila sigurnost.Ono što želim je kada se pokreće bilo koji od senzora (visoki napon u ulazni pin), ona će imati visoki napon na izlazni pin sirena i pozvati unaprijed definirani broj vlasnika.Može bilo tko ček za to i pustiti mene znati što je problem? Hvala.
Šifra:
/ / Preprocessor
# Include <16F877.H>
# Osigurači HS, NOWDT, NOLVP
# KORIŠTENJE KAŠNJENJE (sat = 12000000)
# KORIŠTENJE RS232 (baud = 9600, paritet = N, xmit = PIN_C6, rcv = PIN_C7, bita = 8)/ / Definiranje pin
# Define Siren PIN_B5
# Define CL1 PIN_B4
# Define CL2 PIN_B3
# Define ULTRA PIN_A0
# Define TOUCH PIN_A1
# Define LIGHT PIN_A2
# Define VRATA PIN_A3
# Define REMOTE PIN_A4/ / Globalne deklaracije
int A, B, C, D, RC, EN;
int RC1 [2];
char SENSOR1, SENSOR2, SENSOR3, SENSOR4, SENSOR5, temp;
char P [4];
char S [51];/ / Zvuk sirene
SIREN_ON void ()
(
OUTPUT_HIGH (Siren);
DISABLE_INTERRUPTS (INT_RTCC);
)
/ / Otključaj vrata
UNLOCK void ()
(
OUTPUT_HIGH (CL1);
OUTPUT_LOW (CL2);
)
/ / Zaključavanje vrata
LOCK void ()
(
OUTPUT_LOW (CL1);
OUTPUT_HIGH (CL2);
)/ / Ultrazvučni senzor pokrenuti
SEND_CALL1 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Touch senzor pokrenuti
SEND_CALL2 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Pokreće Svjetlosni senzor
SEND_CALL3 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Vrata senzor pokrenuti
SEND_cALL4 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Centralna brava pokreću
SEND_CALL5 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
# INT_RTCC
T0 ()
(
SENSOR1 = INPUT (ULTRA);
SENSOR2 = INPUT (touch);
SENSOR3 = INPUT (LIGHT);
SENSOR4 = ulaz (vrata);
SENSOR5 = INPUT (CL1);
if (SENSOR1)
(
SEND_CALL1 ();
SIREN_ON ();
)
else if (SENSOR2)
(
SEND_CALL2 ();
SIREN_ON ();
)
else if (SENSOR3)
(
SEND_CALL3 ();
SIREN_ON ();
)
else if (SENSOR4)
(
SEND_CALL4 ();
SIREN_ON ();
)
else if (SENSOR5)
(
SEND_CALL5 ();
SIREN_ON ();
)
)# INT_RDA
SERIAL ()
(
/ / Izborni
if (kbhit ())
(
TEMP = GETC ();
if (<50)
(
S [] = temp;
;
)
drugi
(
= 0;
S [] = temp;
;
)
)
DELAY_MS (100);
povratak, S;
)/ / Glavna funkcija
void main ()
(SET_RTCC (0);
SETUP_COUNTERS (RTCC_INTERNAL, RTCC_DIV_64);
EXT_INT_EDGE (0, H_TO_L);
ENABLE_INTERRUPTS (INT_EXT);
ENABLE_INTERRUPTS (INT_RDA);
ENABLE_INTERRUPTS (GLOBAL);
ENABLE_INTERRUPTS (INT_RTCC);
SET_TRIS_A (0x3F);
SET_TRIS_B (0x01);
/ / SET_TRIS_C (0x0F);
SET_TRIS_D (0x00);DELAY_MS (5000);Printf ( "\ n \ Ratz \ n \ r");
DELAY_MS (500);
Printf ( "\ n \ RAT \ n \ r");
DELAY_MS (500);
Printf ( "\ n \ RAT CNMI = 2,3,0,0,0 \ n \ r");
DELAY_MS (500);SENSOR1 == 0;
SENSOR2 == 0;
SENSOR3 == 0;
SENSOR4 == 0;
SENSOR5 == 0;
= 0;
B = 0;
C = 0;
D = 0;
HR = 0;
RC = 0;
Otključaj ()
Šifra:
/ / Preprocessor
# Include <16F877.H>
# Osigurači HS, NOWDT, NOLVP
# KORIŠTENJE KAŠNJENJE (sat = 12000000)
# KORIŠTENJE RS232 (baud = 9600, paritet = N, xmit = PIN_C6, rcv = PIN_C7, bita = 8)/ / Definiranje pin
# Define Siren PIN_B5
# Define CL1 PIN_B4
# Define CL2 PIN_B3
# Define ULTRA PIN_A0
# Define TOUCH PIN_A1
# Define LIGHT PIN_A2
# Define VRATA PIN_A3
# Define REMOTE PIN_A4/ / Globalne deklaracije
int A, B, C, D, RC, EN;
int RC1 [2];
char SENSOR1, SENSOR2, SENSOR3, SENSOR4, SENSOR5, temp;
char P [4];
char S [51];/ / Zvuk sirene
SIREN_ON void ()
(
OUTPUT_HIGH (Siren);
DISABLE_INTERRUPTS (INT_RTCC);
)
/ / Otključaj vrata
UNLOCK void ()
(
OUTPUT_HIGH (CL1);
OUTPUT_LOW (CL2);
)
/ / Zaključavanje vrata
LOCK void ()
(
OUTPUT_LOW (CL1);
OUTPUT_HIGH (CL2);
)/ / Ultrazvučni senzor pokrenuti
SEND_CALL1 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Touch senzor pokrenuti
SEND_CALL2 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Pokreće Svjetlosni senzor
SEND_CALL3 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Vrata senzor pokrenuti
SEND_cALL4 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
/ / Centralna brava pokreću
SEND_CALL5 void ()
(
Printf ( "ATD0123456789; \ n \ r");
)
# INT_RTCC
T0 ()
(
SENSOR1 = INPUT (ULTRA);
SENSOR2 = INPUT (touch);
SENSOR3 = INPUT (LIGHT);
SENSOR4 = ulaz (vrata);
SENSOR5 = INPUT (CL1);
if (SENSOR1)
(
SEND_CALL1 ();
SIREN_ON ();
)
else if (SENSOR2)
(
SEND_CALL2 ();
SIREN_ON ();
)
else if (SENSOR3)
(
SEND_CALL3 ();
SIREN_ON ();
)
else if (SENSOR4)
(
SEND_CALL4 ();
SIREN_ON ();
)
else if (SENSOR5)
(
SEND_CALL5 ();
SIREN_ON ();
)
)# INT_RDA
SERIAL ()
(
/ / Izborni
if (kbhit ())
(
TEMP = GETC ();
if (<50)
(
S [] = temp;
;
)
drugi
(
= 0;
S [] = temp;
;
)
)
DELAY_MS (100);
povratak, S;
)/ / Glavna funkcija
void main ()
(SET_RTCC (0);
SETUP_COUNTERS (RTCC_INTERNAL, RTCC_DIV_64);
EXT_INT_EDGE (0, H_TO_L);
ENABLE_INTERRUPTS (INT_EXT);
ENABLE_INTERRUPTS (INT_RDA);
ENABLE_INTERRUPTS (GLOBAL);
ENABLE_INTERRUPTS (INT_RTCC);
SET_TRIS_A (0x3F);
SET_TRIS_B (0x01);
/ / SET_TRIS_C (0x0F);
SET_TRIS_D (0x00);DELAY_MS (5000);Printf ( "\ n \ Ratz \ n \ r");
DELAY_MS (500);
Printf ( "\ n \ RAT \ n \ r");
DELAY_MS (500);
Printf ( "\ n \ RAT CNMI = 2,3,0,0,0 \ n \ r");
DELAY_MS (500);SENSOR1 == 0;
SENSOR2 == 0;
SENSOR3 == 0;
SENSOR4 == 0;
SENSOR5 == 0;
= 0;
B = 0;
C = 0;
D = 0;
HR = 0;
RC = 0;
Otključaj ()