HC SR-04 u.sonic sensörlü park sensörü uygulaması

Başlatan overlok, 31 Aralık 2014, 01:22:11

overlok

Selamlar arkadaşlar;

Bu çalışmamda HC SR-04 u.sonik sensörü, buzzer ve led kullanarak "çakma" araç park sensörü yapmaya çalıştım :)
ETE hocanın katkısıyla kodları tamamladım. Açıkçası kodların hepsini direkt ben yazmadım, birleştirdim :) Tabi biraz vaktimi aldı haliyle :)
Sensöre yaklaştırılan cismin mesafesine göre buzzerden ikaz sesi çıkıp portb'ye baglı ledler gene mesafeye göre yanacak, Buzzer'den çıkan ikaz sesi, cisim yaklaştıkça hızlanacak şekildedir. İlgilenenlere kolay gelsin.




@ DEVICE INTRC_OSC_NOCLKOUT , LVP_OFF, MCLR_OFF, WDT_OFF
PORTA=0
TRISA=%00000010
PORTB=0
TRISB=%00000000
CMCON=7
OPTION_REG.7=0

DEFINE OSC 4
w var word
r var word
a var word
m var byte
buzz var portb.4
tr var porta.0
ec var porta.1
w=0
low tr
basla:
high tr
pauseus 10
low tr
pulsin ec,1,w
r=((w*10)/58)
if r<=10 then
portb=%00001000
gosub uc
else 
portb.3=0
endif

if r>=11 and r<=20 then
portb=%00000100
gosub iki
else
portb.2=0
endif

if r>=21 and r<=30 then
portb=%00000010 
gosub bir
else
portb.1=0
endif
pause 200                                                                                                                                                                                                                                                                                                                                                                                  
goto basla

bir:
sound buzz, [116,42]
return

iki:
sound buzz, [116,21]
return

uc:
sound buzz, [116,5]
return


end
 


hex:

:10000000D128B400841780048413A201201CA2000C
:1000100010200319CC2810200319CC281020CC283C
:100020003408A2060130A000A10100083405220610
:10003000031D0800A00A0319A10F15280800A3003A
:1000400036088400340946208413A3080319CC28F9
:10005000F030A50022088038A400F030A503031971
:10006000A5000319A3030319CC283628492003014E
:1000700020183408A21F3408A20803190301A40F92
:10008000432880062A28442800002D28841780054C
:10009000CC28210820040319A00A8030201AA106C8
:1000A0002019A106A018A106210DA00DA10DCC2894
:1000B000A301A200FF30A207031CA307031CCC2846
:1000C0000330A100DF3066205A28A101E83EA000DD
:1000D000A109FC30031C6F28A00703186C28A00797
:1000E0006400A10F6C2820187528A01C7928000036
:1000F00079280800A20003308328A2000130832859
:10010000A20006308328A80023082102031D8A28A4
:100110002208200204300318013003190230280598
:10012000031DFF30CC280038031DFF300405031DDC
:10013000FF30CC28A501A4011030A600210DA40D8C
:10014000A50D2208A4022308031C230FA5020318EF
:10015000B0282208A40723080318230FA5070310BB
:10016000A00DA10DA60B9E282008CC281030A800B9
:10017000A101A001A70CA60C031CC4282208A007FB
:1001800023080318230FA107A10CA00CA50CA40C95
:10019000A80BBA282408CC28831303138312640005
:1001A00008008501831602308500831286018316BC
:1001B0008601831207309F00831681138312C001CA
:1001C000C10105108316051083120514831605104E
:1001D0000A30831265200510831605108312013042
:1001E000A00005308400023001202008C000210852
:1001F000C1004008A6004108A7000A30A200A301E0
:10020000B620BC002508BD003C08A0003D08A100A8
:100210003A30A200A3019A20BA002108BB003A0894
:10022000A0003B08A100A3010A307D20031D1C296A
:100230000830860072211D2986113A08A0003B086B
:10024000A100A3010B307A20BC003A08A0003B08B3
:10025000A100A30114308020BE003C0884003E08A9
:100260009320BE00BF0064003E083F0403193C29F0
:100270000430860069213D2906113A08A0003B0898
:10028000A100A30115307A20BC003A08A0003B0869
:10029000A100A3011E308020BE003C0884003E085F
:1002A0009320BE00BF0064003E083F0403195C2990
:1002B0000230860060215D298610C8305820E5286C
:1002C0000630B6001030B4007430A2002A301F206F
:1002D00008000630B6001030B4007430A2001530AB
:1002E0001F2008000630B6001030B4007430A200A1
:0A02F00005301F20080063007B2981
:02400E00583F19
:00000001FF
Hanımların dikkatine, overlok makinesi ayağınıza geldi!