Touch screen monitor

Posted on 27/08/2011 by santhoshr
Modified on: 13/09/2018
Introduction
This is an automatic import from our previous community platform. Some things can look imperfect.

If you are the original author, please access your User Control Panel and update it.

Hello everybody !!! :) The main aim of this project is to convert a normal computer monitor into a touch screen monitor.. For this I use 2 SRF005 ultrasonic range sensors and 1 picaxe 28X2. The above image is the baisc plan of my project and it will explain you how things work. I use VB.NET to interface between the Picaxe and the computer. My picaxe code is : #picaxe 28x2main:pulsout C.1,2    pulsin C.1,1,w1pause 10let w1 = w1 * 10/62pulsout C.2,2pulsin C.2,1,w2pause 10let w2 = w2 * 10/62sertxd ...


Touch screen monitor

Hello everybody !!! :)

The main aim of this project is to convert a normal computer monitor into a touch screen monitor.. For this I use 2 SRF005 ultrasonic range sensors and 1 picaxe 28X2.

The above image is the baisc plan of my project and it will explain you how things work.

I use VB.NET to interface between the Picaxe and the computer.

My picaxe code is :

#picaxe 28x2
main:
pulsout C.1,2    
pulsin C.1,1,w1
pause 10
let w1 = w1 * 10/62

pulsout C.2,2
pulsin C.2,1,w2
pause 10
let w2 = w2 * 10/62

sertxd (w1," ",w2)

and my VB code is :

 

Imports System.IO

Imports Strings = Microsoft.VisualBasic

Imports System.Math

Public Class Form1

    Public Declare Auto Function GetCursorPos Lib "User32.dll" (ByRef lpPoint As Point) As Long

    Public Const MOUSEEVENTF_LEFTDOWN = &H2

    Public Const MOUSEEVENTF_LEFTUP = &H4

    Private Const MOUSEEVENTF_RIGHTDOWN = &H8

    Private Const MOUSEEVENTF_RIGHTUP = &H10

    Public Const MOUSEEVENTF_MIDDLEDOWN = &H20 ' middle button down

    Public Const MOUSEEVENTF_MIDDLEUP = &H40 ' middle button up

 

    Declare Function apimouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean

 

    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)

    Dim WithEvents serialPort As New IO.Ports.SerialPort

    Dim PicaxeRegisters(0 To 2) As Byte

    Dim w1 As Integer

    Dim i As Integer

    Dim var As Integer

    Dim w2 As Integer

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Timer1.Enabled = True

        Timer1.Interval = 1000    ' the interval at which the serial port accepts the data & this can be varied

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

 

        Call SerialTxRx()

    End Sub

    Sub SerialTxRx()

 

        Dim labelstring As String

        Dim labelstring1 As String

        If serialPort.IsOpen Then

            serialPort.Close()

        End If

        Try

            With serialPort

                .PortName = "COM1"

                .BaudRate = 9600

                .Parity = IO.Ports.Parity.None

                .DataBits = 8 ' 8 bits

                .StopBits = IO.Ports.StopBits.One

                .Open()

                .DiscardInBuffer()

                Call Sleep(100)

                .Read(PicaxeRegisters, 0, 3)   ' the 3 is because of the 2 values of the SRF005 + 1 space between the two values

                .Close()

            End With

            Label1.Text = PicaxeRegisters(0)

            Label2.Text = PicaxeRegisters(2)

            labelstring = PicaxeRegisters(0)

            labelstring1 = PicaxeRegisters(2)

 

            If PicaxeRegisters(2) < 116 And PicaxeRegisters(0) < 123 And PicaxeRegisters(0) > 2 And PicaxeRegisters(2) > 2 Then ' limits

                Dim x As Double

                Dim y As Double

 

                If PicaxeRegisters(2) > 30 Then

                    x = (112 - labelstring1) * 18   ' 112 is the extreme value of x & it depends on your monitor

                    y = (120 - labelstring) * 18    '120 is the maximum value of y

                    '18 used to convert the SRF005 value's unit to pixel. My 

                    y = 900 - y                     ' 900 is the maximum pixel value(because my monitor is a 1440 X 900 monitor

                    Me.Cursor = New Cursor(Cursor.Current.Handle)

                    If x > 700 Then

                        x = x + (x - 700) * 0.25 'to maximise accuracy, increase or decrease 0.25 according to your convinience

                    End If

                    Cursor.Position = New Point(x, y)

                Else

                    Call apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

                End If

                Label3.Text = x

                Label4.Text = y

            Else

                Call apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

            End If

        Catch ex As Exception

            MsgBox(ex.ToString)

            Label1.Text = "Timeout"

        End Try

   End Sub

End Class

What this does is : The two SRF05 sensors send the distance values (horizontal and vertical) to the COM port, which is recieved by the VB code and it makes some calculations as shown above to move the cursor to the position where you pointed to. 

 

You can also use " Call apimouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0)" and " Call apimouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0)" to deal with scrolling

 

 

 

This project is not very tough to make, but it takes a lot of time and patience to do it... Please give me some suggestions and improvements(if any) as comments.

Thank You

Takes the mouse pointer to the position where we point depending on the distance given by the two SRF05

  • CPU: PICAXE 28X2
  • Operating system: Windows 7
  • Power source: 9V (with 5V regulator)
  • Programming language: Picaxe basic
  • Sensors / input devices: SRF05 Ultra Sound
  • Target environment: indoor
Flag this post

Thanks for helping to keep our community civil!


Notify staff privately
It's Spam
This post is an advertisement, or vandalism. It is not useful or relevant to the current topic.

You flagged this as spam. Undo flag.Flag Post