|
-
Jul 26th, 2001, 02:20 AM
#1
Thread Starter
New Member
help!!!!!!!!!!!!!!!!!!1111
as i was saying i have 4 led like led1, led2,led3,led4
and my program is a 4 bit counter which counts from 0000, 0001, 0010....to 1111. so what is the code to make the led light up whenever my string of numbers shows a 1. example
when 0010 is being input, the 3rd led is being light up the rest are all off.
to light the led the command is led3 = true
thanks for helping guys/gals
-
Jul 26th, 2001, 02:44 AM
#2
Fanatic Member
Try:
VB Code:
Led1 = (Mid(CStr(Counter), 1, 1) = 1)
Led2 = (Mid(CStr(Counter), 2, 1) = 1)
Led3 = (Mid(CStr(Counter), 3, 1) = 1)
Led4 = (Mid(CStr(Counter), 4, 1) = 1)
-
Jul 26th, 2001, 02:52 AM
#3
Retired VBF Adm1nistrator
I'm trying, and I keep trying, but I cant come up with any code any more snug than that of InvisibleDuncan's
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jul 26th, 2001, 03:38 AM
#4
-= B u g S l a y e r =-
sqapg
sample for u
-
Jul 26th, 2001, 03:43 AM
#5
Retired VBF Adm1nistrator
I prefer my binary converter
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jul 26th, 2001, 03:51 AM
#6
-= B u g S l a y e r =-
-
Jul 26th, 2001, 03:59 AM
#7
Registered User
Perhaps a control array will trim it?
VB Code:
For i = 0 To 3
Check1(i) = Mid(b, i + 1, 1)
Next i
To test it add 4 checkboxes in a control array and a command button, then add the code. Press the button to "count".
VB Code:
Option Explicit
Dim c&
Private Sub Command1_Click()
Dim b$, i&
If c > 15 Then c = 0
b = Format$(bin(c), "0000")
For i = 0 To 3
Check1(i) = Mid(b, i + 1, 1)
Next i
c = c + 1
End Sub
Function bin(ByVal X As Long) As String
Do
bin = (X And 1) & bin
X = X \ 2
Loop While X
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|