Read SW1 status and check serial for data at same time
Posted 15 November 2011 - 10:14 PM
Posted 16 November 2011 - 07:26 AM
Have you tried using the DataReceived event instead? That way you can grab data once it arrives, instead of just waiting for it?
You could also put some of your code on another thread, so it ran in parallel...
plase find the code underneath:
'Serial port declaration
Private WithEvents NDSerial As SerialPort
'Wait for some event rises
Private Sub SerialIn() Handles NDSerial.DataReceived
'HERE THE PROBLEM, I DON'T KNOW WHERE PLACE THE FOLLOWING CODE (OR SOMETHING SIMILAR) IN ORDER TO CHECK THE BUTTON STATUS OR BETTER, RISE AN EVENTS WHEN IT HAS BEEN PRESSED
'Read ND+ button status
Thanx a lot for ur support!
Posted 16 November 2011 - 07:43 AM
Posted 16 November 2011 - 08:19 AM
You have to declare the switch as InterruptPort, so you will receive an event whenever it changes (as you receive interrupts with serial communication):
Private WithEvents SW1 As new InterruptPort(Pins.GPIO_PIN_6, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh)
Now it's clear.
Thanx a lot!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users