• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 9 رای - 2.56 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: فعال کردن رله از طریق تاچ صفحه نمایش !!!
حالت موضوعی
#1

.zip   Touch-Screen.zip (اندازه 871.39 KB / تعداد دانلود: 1)
کد پی‌اچ‌پی:
$regfile "m32def.dat"
$crystal 8000000

$lib 
"glcdks108.lib"

Config Graphlcd 128 64sed Dataport Portb Controlport Portd Ce Ce2 Cd Rd Reset Enable 2       'Config Graphic LCD Pins
Config Adc = Single , Prescaler = Auto , Reference = Avcc   '
Config A/D Devices
Config Portc 
Output :                                     'Normaly Off
Dim X As Word , Y As Word                                   '
Dimension X And For Touch Pad
Dim Lcds 
As Byte Lcds 1                                 'Dimension Picture Number Variable
Dim Row As Byte , Col As Byte                               '
Dimension Row And Col Variable
Dim Inter 
As Byte
Cls

'Cd = Rs
'
Ce Cs1
'Ce2 = Cs2
'
Rd R/W
'Enable = E
'
Vcc RST VCC
Up
:
Do
   
Gosub Readtouch                                          'Read Where is Selected
   Gosub Whichkey                                           '
Read Which Key is Selected
   Gosub Glcd                                               
'Change LCD Statues
   Waitms 220
Loop

End                                                         '
END Of Program


Readtouch
:
Config Pina.0 Output                                      ' Makes port A.0 output
Config Pina.2 = Output                                      ' 
Makes port A.0 output
Set Porta.0                                                 
' Sets port A.0 High
Reset Porta.2                                               ' 
Sets port A.2 Low
Ddra.1 
0                                                  ' Sets port A.1 as input
Ddra.3 = 0                                                  ' 
Sets port A.1 as input  because we need it now as ad input
Waitms 20                                                   
' Wait until the port is stable
Y = Getadc(3)                                               ' 
Read the ad value for the y
'Print "VALUE Y : " ; Y                                      ' for debugging
Config Pina.1 
Output                                      ' Makes port A.1 output
Config Pina.3 = Output                                      ' 
Makes port A.3 output
Reset Porta.1                                               
' Sets port A.1 Low
Set Porta.3                                                 ' 
Sets port A.3 High
Ddra.0 
0                                                  ' Sets port A.0 as input
Ddra.2 = 0                                                  ' 
Sets port A.2 as input  because we need it now as ad input
Waitms 20                                                   
' Wait until the port is stable
X = Getadc(2)                                               ' 
Read the ad value for the x
'Print "VALUE  X : " ; X
Return

Whichkey:
Select Case X                                               ' 
For the Column value
            
Case 740 To 900 Col 1
            
Case 130 To 300 Col 2
            
Case Else Col 0
End Select
Select 
Case Y                                               ' For the Row value
            Case 225 To 490 : Row = 1
            Case 560 To 800 : Row = 2
            Case Else Row = 0
End Select
'
Select State
If Col And Row 1 Then
   Incr Lcds
   
If Lcds 8 Then Lcds 8
End 
If
If 
Col And Row 1 Then
   Inter 
Lcds 1
   Reset Portc
.inter
End 
If
If 
Col And Row 2 Then
   Decr Lcds
   
If Lcds 1 Then Lcds 1
End 
If
If 
Col And Row 2 Then
   Inter 
Lcds 1
   Set Portc
.inter
End 
If

Return


Glcd:
Select Case Lcds
   
Case Showpic 0 1
   
Case Showpic 0 2
   
Case Showpic 0 3
   
Case Showpic 0 4
   
Case Showpic 0 5
   
Case Showpic 0 6
   
Case Showpic 0 7
   
Case Showpic 0 8
End Select
Return

'Graphic Character's
1
:
$bgf "1.bgf"
2:
$bgf "2.bgf"
3:
$bgf "3.bgf"
4:
$bgf "4.bgf"
5:
$bgf "5.bgf"
6:
$bgf "6.bgf"
7:
$bgf "7.bgf"
8:
$bgf "8.bgf" 

 

 
[عکس: bnk.png]

برای ورود بر روی تصویر کلیک کنید.
www.avrprj.ir
 
پاسخ
  


پرش به انجمن:


Browsing: 1 مهمان