Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




LED Lights Blinking Via Parallel Port - Trouble With Timers


Greetings to all, I am having small issues with a Visual Basic 6 code I am working on to widen my knowledge. I'm new to the programming scene, hopefully someone here will be able to help.

I'll be lighting up LED lights via Parallel Port. My code is written in Vb6. I'm using the inpout32.dll to send my signals to the pins. I am using a breadboard to establish the circuit. Basically what I am having trouble with it's to make the LED's blink at an X amount of seconds. I've managed to this with a 555 Timer directly onto the breadboard. Now I'm having trouble with Vb6 Timers to do this. I have little knowledge about Timers, everything I read about it isn't really helping me. I'll paste my code down here and try and explain it as well as I can in English.

MAIN PROBLEM : The light won't blink every one second, it turns on but does not blink.

Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal sgnGo As Integer) As Integer

Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal sgnGo As Integer, ByVal Value As Integer)


'Variable to send the signals to the pins

Dim sgnGo As String
Dim onOff as Long

'The HEX code for the LPT1 port defined in form_load
Private Sub Form_Load()

Timer1.Stop
sgnGo = &H378

End Sub

'Out is to simply send the signal to the pin using inpout32.dll

Private Sub pn1_Click()
Timer1.Start
Out sgnGo, 1
End Sub

Private Sub Timer1_Timer()
Timer1.Interval = 1000 'This is suppose to be making the LED
'blink on and off every 1 second.
onOff = onOff Xor 1
Out sgnGo, onOff
End Sub

Private Sub pn2_Click()
Out sgnGo, 2
End Sub

Private Sub pn3_Click()
Out sgnGo, 4
End Sub

Private Sub pn4_Click()
Out sgnGo, 8
End Sub

Private Sub pn5_Click()
Out sgnGo, 16
End Sub

Private Sub pn6_Click()
Out sgnGo, 32
End Sub

Private Sub pn7_Click()
Out sgnGo, 64
End Sub

Private Sub pn8_Click()
Out sgnGo, 128
End Sub

'Procedure to turn off LED lights
Private Sub sgnArret_Click()
Out sgnGo, 0
End Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Using The Parallel Port To ControlXmas Lights
G'Day,

I am wondering if there is any one can help, I have put together a kit to connect to the parrallel port that will switch up to 8 relays, it did not have software with it. i have a limited knowledge of VB.

I have done a search, and have a ittle more understanding, I have seen that you need inpout32.dll. That is as far I can make out.

Is there some code or software that I can use to contol the kit.

Thanks in advance

cfer

Controlling Lights With Parallel Port?
Hi im Justin Hulbert,

I need alot of help i want to somehow make a program that I can use to control lights from my computer. I know how to build the circut and optical relays (alredy built a few). Just simple where i can click a button to turn a chanel on or of. Probaly build a circut for all 8 chanels so i would need a total of 16 buttons.

I have downloaded VB 05 Ed and have never programed befor. Maybe you could sugest a site or book. Im geting realy into electronics lattly and feal i could build cooler things if i learn to program. I just thought this would be a relitivly essay project to start with. In our enginering calss at school we use a drag and drop program, whitch has its limitations. I hope someone can stear me in the right directon.


New Member:
Justin Hulbert

Parallel Port Interface Real Time Counter Trouble.
Greetings to all, I am having small issues with a Visual Basic 6 code I am working on to widen my knowledge. I'm new to the programming scene, hopefully someone here will be able to help.

I'll be lighting up LED lights via Parallel Port. My code is written in Vb6. I'm using the inpout32.dll to send my signals to the pins. I am using a breadboard to establish the circuit. Basically what I am having trouble is to code a counter that can count how many times the LED light is blinking. I have little knowledge about Timers, everything I read about it isn't really helping me. I'll paste my code down here and try and explain it as well as I can in English.

MAIN PROBLEM : Coding a counter that can detect how many times the LED light blinks in real time. I know how to make the light stop blinking after X amount of seconds, that's simple to do. I am just lost on how to be able to make the counter detect how many times it's actually blinking in real time.

Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal sgnGo As Integer) As Integer

Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal sgnGo As Integer, ByVal Value As Integer)


'Variable to send the signals to the pins

Dim sgnGo As String 'Variable to send the single
Dim onOff as Long 'Variable to make the LED blink on/off

'The HEX code for the LPT1 port defined in form_load

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Timer2.Enabled = False
Timer2.Interval = 2000
sgnGo = &H378
End Sub

'Out is to simply send the signal to the pin using inpout32.dll

Private Sub pn1_Click()
Timer1.Enabled = True
Timer2.Enabled = False
Out sgnGo, 1
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer2.Enabled = False
onOff = onOff Xor 1 'Light blinks on/off every 1 second
Out sgnGo, onOff
End Sub

Private Sub pn2_Click()
Timer2.Enabled = True
Timer1.Enabled = False
Out sgnGo, 2
End Sub

Private Sub Timer2_Timer()
Timer2.Enabled = True
Timer1.Enabled = False
onOff = onOff Xor 2 'Light blinks on/off every 2 seconds
Out sgnGo, onOff
End Sub

'Procedure to turn off LED lights
Private Sub sgnArret_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Out sgnGo, 0
End Sub

How To Get Data From Serial Port /parallel Port
How do you capture data sent through the
serial/parallel port coming from another machine(lets
say from a pabx machine sending strings of data).

Is it possible to save the data to a txt/csv file for
processing? how?

Trouble With Timers...
I have a problem in my game. You see, in my first level, I have a timer that counts down from 60 to 0 every second, and displays that variable in a label. When you win that level, it takes you to the next level (first it shows the next form, then it unloads the previous form). The problem is that when I get into the next level, the label decrements by 2's every second instead of by one every second! I think it's because the timer from my previous form is somehow still running, and every second both timers are decreasing my time variable by one. However, I made sure that before my first form unloads itself, it sets the timer's enabled property to false, but even that doesn't work!

Trouble With Timers
Hmm... I'm having trouble with something I believe should be pretty simple.
All I'm trying to do is have a simple digital clock on a program.

I know how to display the time & date, but I can't figure out how to get it to 'work'. I've tried getting it to refresh each second (1000 = 1 second i believe in VB)... but still no luck.

Do I even need to use a timer control or not ?

Grrrr, help ? LoL

The Trouble With Timers
having trouble keeping my timer from causing a loop. here's what i'm trying to do.

i've set the timer to check the system time to and once the sytem time is greater than (or equal to) a preset time a message box pops up. the only problem is that every instance after the inital trigger is greater than the preset time so the messege box pops up over and over-esentially locking up the system.

here is the code i have so far. please let me know how to fix this. i've got everything else in the program going so this is the only thing holding me back. thanks

_______________________________________________________
Private Sub tmrAlert_Timer() 'timer interval set at 1'
Dim AlerTime As Date
Dim smgsAlert As String

alerttime = Format(0.5625, "short time") 'triggers alert at 1:30pm'

If Time >= alerttime Then
smgsalert = "alert."
MsgBox smgsalert

End If
_________________________________________________________
i'm pretty new at this (this is my first program) so don't be afraid of talking down to me, i doubt it could be done. examples are helpful and i promise not to copy your code and pass it off as my own.

thanks again
toddler

How Can I Use A Parallel Port?
Hello.

Does anybody know how can I use the parallel port with Visual Basic?

What commands must I use to use it?

Thank You.

About Parallel Port
Hi there,
From all the input pin in the parallel port (pin 10 - pin 13 and pin 15), can i just read only 1 of those pin as an input?? Example, i connect pin 10 to an external circuit. How can i read input data from only pin 10 and ignore other pins??
Can anyone please tell me the code??

Thanks a lots.

Parallel Port
Hiya guys - what im after is some info on parrallel port usage - i want to write a piece of software to operate electric windows in my car.

So basically I will need the parallel port to be wired to the motors instead of the switch and to act as a switch.

So here goes - there a 3 wires on each switch - power / up / down
Im thinking i will 2 wires for each window out of the port and to the motor - basically signal wires.

So what is the way using code that I can send the signal to the specific pin on the port as I've never touched using parallel for anything before.

Also if it needs a power in could it be possible to simmulate shorting 2 pins to send the in straight out the out if that makes sense

Hopefully someone knows the way forward on this as I dont have an ankles dangle.

Parallel Port
I am new to VB. Currently i am using parallel port to read and write data to a chip using VB. What is the difference between Address write and data write.

How do i read from the chip register address??
How do i write to a specific addr on the chip??

cheers

Parallel Port Bit
hi
has anyone been able to set certain bits on and off with out changing the other bits

say you have bit pattern 00000101
and you want to change it to 00000100
with just the 2 changes here it would be simple to command a 4 instead of a 5 but how to do this on a every bit.
anyideas?

Parallel Port!
hi all experts,

I am using a motion detector and parallel port interface on my application. Parallel port program used is (TvicLpt)

When the motion detector detects something, it triggle one of the wire in the motion detector to high (1).

Is there any solution to detect the high (1) by by the parallel port and alert me on the VB program so that i know that there is motion detector.


Thank you

Parallel Port
hi,
I need to create square pulse to sent from my parallel port pin 3 to drive my stepper motor.

Example, I create a command button in my form, when pressed, it suppose to generate example 3 square wave, so that my stepper motor will turn 3 step.

Pls help me on the VB code actually how to generate pulses and also how to generate specific pulses (eg. 3 pulse) from the parallel port pin 3.

Thank you very much.

Justin Mun

Parallel Port And Win XP
I am trying to send a single bit to my parallel port but can not figure out how to do it in VB. If anybody knows how in either VB6 or .NET it would be much appreciated.

Thanks A lot!!!

Geoff

VB & Using A Parallel Port
I need to know a simple yet hard (for me) program to control a printer port I/O. I need just 8 buttons (since it has 8 outputs and 8 inputs). The button does two things:

Push the button and the object (for testing purposes i will use a LED) turns on.

Push the button again and the object goes off.

Simple as that, but i dont know where to start of how i would hook up the LED on the printer port? Do i hook the positive side of the LED to port 2 and the other side as a ground (port 15 or somthing). and do i have to connect it again from port 10 (input) to turn it off? Any help would be great!

Thanks,
David

Parallel Port
Hi all,

I am an undergrad and I'm helping my uni out in upgrading/modifying some lab experiments. I have the source code in C++ for reading some values from a A/D converter through the parallel port to the computer. I wish to use VB to try and do the same thing but have been unsuccessful. I've using Jan Axelson's inpout16.dll and inpout32.dll for port access. Can anyone tell me how to access the individual pins?

The code is as follows:

#define OutPort 0x0278 // address for output port (8 bits)
#define InPort 0x0279 // address for input port (5 bits)
#define Address 0x027A // address for selecting device (8bits)
#define NONE 0x0F // deselect device
#define A2DL 1 // A/D low nibble
#define A2DH 2 // A/D high nibble

main()
{
int readl, readh, value;

outp(Address, A2DL); // use 'outp' function to select user port 'A2DL'
readl = inp(InPort); // store the reading
outp(Address, NONE); // deselect the user port

readl = (readl>>4); // right shift the reading by 4

outp(Address, A2DH); // use 'outp' function to select user port 'A2DH'
readh = inp(InPort); // store the reading
outp(Address, NONE); // deselect the user port

value = ( (readh & 0xF0) | (readl & 0x0F) );
}

any help is greatly appreciated......

vance

ISR For Parallel Port
I wrote an ISR in C++ to read data from parallel port and save it to an array.
The ISR runs perfectly in DOS but not in windows.
I need to re-write the ISR to work in windows and be assigned a high priority so as not to be masked by other interrupts.
what can i do ??

Parallel Port In VB
How to send output to parallel port using vb6?
How to get input from parallel port?

if the input of parallel port is not connected, is it consider "high" or "low"?


thanks.......

Parallel Port ..........
Hi Friends,

i want read commands from Parallel Port by visualbasic ,

is there any control in vb for that??
like(rs232 we have mscomm)..

or any other way to do that??

any example or source or info..??

waitng for your valuable reply..


with regards,
Krish..

VB6 And Io.dll Parallel Port
How can i program in VB, that everytime there is a signal(1 bit) coming from one pin of the parallel port, there would be a counter and a label that would increment


Particular example, if i inserted a coin in a coin slot module that is connected to the parallel port of the PC, how will i program from VB that a signal had come?

Somebody told me to use io.dll?? but i don't know how will i use id especially in VB..

Need you help guys.. thanks in advance!

Parallel Port
hello!
I try to access(read & write) in vb6 the parallel port of my pc.
can anyone help me to find a solution for my problem?
yours,with respect,
mariani

Parallel Port
hey guys can u plz provide me with a vb code that receives the content of 8 bits from the parallel port of the pc send by a microcontroller, on a command button click! ths in advance

Parallel & USB Port
How can i access Parallel port in vb..?
How can i access USB port in vb..?


I know how to access serial port in vb

Parallel Port
Hey all, I know this post is in the wrong place but didnt know where else to go!

I am coding a program to control the Parallel port , i need it to control 18 different relays. Is this Possible?

I have only seen examples of up to 8 relays being controlled.

Anyone have experience in this area?

thanks and once again sorry for the misplaced post

VB To The PC's Parallel Port
Hi. Need some help interfacing devices via VB to the parallel port.

With my project, im also designing a sort of alarm system, where a PIR device will activate the software that follows - face recognition.

I need to know if anyone can help with using this device with the port. Ive read bout using the interrupt pin on the port, but am not sure how to interface the devices.

Please help. Thanx

Parallel Port
Is there any DLL or code to read/write from/into the PPP (Parallel Port Printer) with Windows 2000?

Parallel Port
The parallel port, can be used by interruptions, such as the serial port?
I've heard of it some time ago, but have no ifdea how to implement it. (I need to make time measurements of an event outside de PC, and my timing is not accurate enough)
Thanks in advance.

Using VB With Parallel Port
Can anyone help me find information on using VB to analyse data coming in/going out of parallel port. Are there any controls for LPT?

Parallel Port In Win NT
Does anyone know of an OCX or dll that is FREE and will control the parallel port IO in winnt?

Parallel Port
Is there a way to send signals trough parallel port with VB?

Parallel Port
I have bought a Null-Modem Cable. Inside that, ther are 25(!) cables in all colors. I have cut the cable, and I want to know what color what does.
Does anybody know that, or a site from where I can get that information?
Thank you.

Parallel Port
Is there a way to send bits through the parallel port?

Using Parallel Port
I wanna interface parallel port with VB.
Can anyone give me advice that how can I do that easily ?

Parallel Port...
I have read all faq's and anything else for parallel port and visual basic.

I have a few question about parallel port.

How can i send and recieve signal in parallel port.
How can i send a singal in one pin of 25 in parallel port and how can i get a singal from one pin.
I dont want to send files or somethink else.
I want to contol the 25 pins and sent on it voltage and get from parallel port this signal.

I try to show you how can i think it

|---------------------------|
|. . . . . . . . . . . . .<-- Pin 13
| . . . . . . . . . . . . |
|---------------------------|

How can i sent and recieve the voltage in this pin or in other's pins

Thanks...

[Edited by Civil78 on 05-06-2000 at 10:42 AM]

[Edited by Civil78 on 05-06-2000 at 10:47 AM]

Parallel Port
how could I approach directly to the parallel port, without use the printer driver?

Parallel Port
Hi.
Try,

http://www.lvr.com/parport.htm

Al.

Parallel Port Using Vb6
Hi,
I want to know what component I should add and how to set the lpt parallel port. Please help me in coding how to send and receive data over parallel port using vb6. very urgent.
Thanks in advance.

Parallel Port
Hello,
i've build a interface for my parallel port, I've written some software in
C++ and in Borland Pascal. But I just dont know how to control the parallel
port in Visual basic 5.0

Please can anybody explain me, or send me a piece of source code that shows
how to control the parallel port.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~

Help! Parallel Port I/O
I m trying get familiar with doing various types of input and ouput with the parallel and visual basic 6. I have the inpout32.dll but have no idea of how to use it.

If anyone has any code samples or tutorials it would be very helpful thanks.

SPI On PCs Parallel Port
SPI on PCs parallel port
Hi I have Visual Basic 6.0 enterprise edition, but have only wrote
some simple code examples from a beginner's book.
I would like to read an SPI device but using my PCs Parallel port.
I just need to send out an 8-bit word and simultaneously read back in
an 8-bit word.
I can simply repeat for multiple words.

It can be as simple as a window that I can enter the hex or binary (or
decimal) number to be sent out and another window for the returned
data.
Then just a button to start the transfer.

Does anyone have something like this?
Or do they know of anything similar?

I have searched the web and the closest that I could find was very
complex and difficult for a beginner to modify.

Using Parallel Port
Hi people:

I need to learn to use the parallel port with VB, I know how to Write a data, but i do not know how to read it, can i use the word inp()? but how?


Thanks People

Parallel Port
how can i program under XP so that i can control a specific data pin on the parallel port
for example: how could i make a LED connected to pin2, D0, light up on command?
also does any one of a easy way of accessing the parallel port under XP?
any info would be great.

Using Parallel-Port With V.B.
Hello,
I want to use the P-port in my V.B project for a work I'm doing. How can I read the P-port thru V.B ? Do I need a special component to do this job..? Does anyone know of a site that distributes a component that does this ?
Please help
Thank-you

LED

Vb Parallel Port
Hi,

I am doing the control of the stepper motor via VB Parallel Port.

I need to sent in the Square Wave Pulse to the Stepper Motor so that it can turn.

I have a command button in the Form, meaning when i run the program, and i click the button . its suppose to generate the Square Wave to the Stepper motor. Example, if i want the motor to turn 3 round then i need to have 3 square pulse.

I new in Vb, and i need the code for actually how to generate specific (Meaning example only 3 square pulses) Square Pulse via Parallel Port (Pin 3) to the Motor badly.


Thank you for Helping me.

Parallel Port
hi how do you send data to/from parallel port .
i am designing an interface b/w pc & a device that uses spi-bus
thanx
myahya@yahoo.com

VB6 And Parallel Port
I am Using VB6.0. I was looking for some control/dll which could write a string(a hexa value) to the parallel port of PC (to switch on and switch off a device) attached to parallel port.


Thanx

Parallel Port
How can I take control over indiviual pins of parallel port from Visual Basic

Parallel Port
hi friends
do you know any dll for paralel port
and please tell me
What are the functions of dll to read and write from paralel port

Copyright 2005-08 www.BigResource.com, All rights reserved