Show Posts
Pages: 1 ... 11 12 [13] 14 15
181  Using Arduino / Motors, Mechanics, and Power / Re: Fan and Digital Input on: May 09, 2012, 04:45:25 pm
It looks like your moter is not connected to any of the I/O pins. Connect one leg of the motor to Pin 3 and the other to ground, designate pin 3 as output  You might designate pin 4 as input then connect your switch between +5 V and pin 4... then make the code in your loop turn on pin 3 when you turn on pin 4 by pressing the switch.

This will be a much more complicated way of doing just what you are now, but at least it will be under program control and you will have written your firt program! You should be able to get some good ideas from looking at the examples that come with the IDE.
182  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 08, 2012, 09:08:37 pm
just use the code that I posted last... the other code snippets were examples based on some of the things I did to get a temperature reading to control a kiln
183  Using Arduino / LEDs and Multiplexing / Re: sketch to control an led ilumination on: May 08, 2012, 06:57:09 pm
go to examples/basic/blink in the Arduino programming environment...that's what it's there for
184  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 08, 2012, 06:41:01 pm
Here is some VB6 code I put together from your code...
I added a text box as Text1 so that you would know what the pressure is

Code:
Option Explicit
' this is added to allow the sleep call
Private Declare Sub Sleep Lib "kernel32" ( _
    ByVal dwMilliseconds As Long)


Private Sub Form_Load()
  With MSComm1
        If .PortOpen Then .PortOpen = False
        .CommPort = 7 ' *************** YOU MAY NEED TO CHANGE THIS OR ADD MY CODE TO FIND THE COM PORT************************
        .Settings = "9600,N,8,1"
        .DTREnable = True
        .RTSEnable = True
        .RThreshold = 4
        .SThreshold = 3
        .PortOpen = True
  End With
 
End Sub

Private Sub LEDOn(col As Long)

 Shape1.BackColor = col
End Sub

Private Sub LEDOff()

 Shape1.BackColor = &HFFFFFF
End Sub


Private Sub MSComm1_OnComm()
Dim strData As String
Static strBuffer As String
Dim strWords() As String
Dim intPos As Integer
Dim boComplete As Boolean
Dim mystr As String

        Sleep 1000 ' this waits one second between readings from the Arduino
        mystr = "" ' set the string to nothing
        mystr = MSComm1.Input
     
   
            intPos = InStr(mystr, "<")
            If intPos > 0 Then
           
                Select Case Mid(mystr, 1, 3) ' strip off the CR/LF
                    Case "<Y>"
                        Text1.Text = ("The pressures value is 80 psi")
                        Call LEDOn(&HFFFF&) ' this is in hex
                    Case "<B>"
                        Text1.Text = ("The pressures value is 60 psi")
                        Call LEDOn(&HFF0000) ' this is in hex
                    Case "<R>"
                        Text1.Text = ("The pressures value is 20 psi")
                        Call LEDOn(&HFF&) ' this is in hex
                    Case "<G>"
                        Text1.Text = ("The pressures value is 40 psi")
                        Call LEDOn(&HFF00&) ' this is in hex
                    Case Else
                       Call LEDOff
                End Select
         End If

End Sub

here is the Arduino code I used to send the info to the VB code, based on your code.
I eliminated some of the logic in your rev because I did not know what it did, and I wonder if you did. It seemed to have njot much to do with what you are looking for. You can put it back in is you need it.

Code:

void setup()
{               
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(7, OUTPUT);
  Serial.begin (9600);
}
void loop()
{

  int a = digitalRead (2);
  int b = digitalRead (3);
  int c = digitalRead (4);
  int d = digitalRead (5);
  //digitalWrite (7,LOW);
  {
    if (a == HIGH)
    {
      digitalWrite (9, HIGH);
      Serial.println ("<R>");
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);

    }
    else if (a == LOW)
    {
      digitalWrite (9, LOW);

    }

    if (b == HIGH)
    {
      digitalWrite (10, HIGH);
      Serial.println ("<G>");
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);
     
    }
    else if(b==LOW)
    {
      digitalWrite (10, LOW);
     
    }

    if (c == HIGH)
    {
      digitalWrite (11, HIGH);
      Serial.println ("<B>");
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);
      delay (200);
      digitalWrite (7, HIGH);
      delay (400);
      digitalWrite (7, LOW);
     
    }
    else if (c==LOW)
    {
      digitalWrite (11, LOW);
     
    }

    if (d == HIGH)
    {
      digitalWrite (12, HIGH);
      Serial.println ("<Y>");
      delay (200);
      digitalWrite (7, HIGH);

    }
    else if (d==LOW)
    {
      digitalWrite (12, LOW);
 
    }

  }
}

It works for me... it should work for you... give it a try!
185  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 08, 2012, 09:55:21 am
 hi Glennmars ... just like michael_x says... It's time you slowed down and started to learn to use the VB and Arduino IDE's

If you don't know even how to set a break point or view a debug window, then you must learn.

If what you are doing is just a one time project, then I think you might be able to work your way through it by just using examples off the internet. If you want to continue you just have to learn your code and that takes time and a hell of a lot of patience.

You already have what you need for the communication between VB and Arduino. That is kind of the hard part. The rest is learning to code in VB6

Good luck
186  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 07, 2012, 09:25:01 pm
too many end subs... did this compile?
Code:
Private Sub LEDOn(col As Long)
End Sub
Shape1.FillColor = col
End Sub

Private Sub LEDOff()
End Sub
Shape1.FillColor = vbWhite
End Sub 


On the arduino side you need to output

Code:
    Serial.print("< ");
    Serial.print(ColorStr);       // output to computer USB port
    Serial.println(">");

On the VB side you need to get the vale back out of the string coming in from the Arduino. Then use ColorStr in your case statement
Code:
  strt = InStr(str, "<") + 1
  fin = InStr(str, ">")
  If (fin - strt) <= 0 Then
     Exit Function
  Else
      ColorStr =  Mid(str, strt, (fin - strt))
  End If

You should be able to piece this together and get it working. Get one piece working at a time. learn to set breakpoints and step through the VB code. It will help a lot also if you use lots of debug statements till you get the thing worked out
187  Topics / Interactive Art / Re: Audio Installation on: May 07, 2012, 06:22:59 pm
Just use cheap micro-switches in the floor. they are easy to wire up and should work as well more expensive solid state switches
188  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 07, 2012, 06:08:22 pm
Woops! got the "<" and ">" backwards on my last post. They are not consistent with my previous code... sorry. turn them around and try it.
189  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 07, 2012, 06:03:35 pm
You may be finding the wrong com port. You have COM1  hardwired into the VB code.

You need to look at what the Arduino IDE is using for your board and use that instead

The code below is what I use to make sure that I am seeing output from my board. It look for a specific string input and then selects that COM port

You can tweak the code to give you what you want

Code:
MSComm1.Settings = "9600,N,8,1"
FoundIt = False
' find USB port
ComFail = False
FailErr = False
For n = 1 To 16
  If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
   On Error Resume Next
   MSComm1.CommPort = n
   On Error Resume Next
   MSComm1.InputLen = 0
   MSComm1.PortOpen = True
   If MSComm1.CommID > 0 Then
     For i = 1 To 100
      str = ""
      str = MSComm1.Input
      If InStr(str, "<") > 0 And InStr(str, ">") > 0 Then GoTo  jump: ' in this case the output from Your Arduino  would be "< R >" or  "< Y >" of < G > "....
      Sleep 50
     Next i
  End If
Next n
If MSComm1.PortOpen = False Then MsgBox "Controller Not functioning , Please check USB connection", vbCritical, "": ComFail = True: Exit Sub

jump:
     '   your case statement
190  Development / Suggestions for the Arduino Project / Re: Arduino 1.0 string changes require changes to examples on: May 07, 2012, 04:19:32 pm
Don't feel bad Paul. For years I was a VB programmer... then after VB6 good old MF... excuse me I meant MS ...Freudian slip. Good old MS decided that VB was not sophisticated enough so they ripped the shit out of it and made it into a lame Java or C# clone. I tried to re-compile a major app I was working on and got 670 error messages! Needles to say I did not and have not migrated.

Anyway you tried... Thanks
191  Using Arduino / Interfacing w/ Software on the Computer / Re: arduino+vb6 on: May 06, 2012, 09:24:04 pm
try this ...
Code:
' set up for the input....

 str = MSComm1.Input  ' get the string
 str = Left(str,1)  ' chops off the first char
 Debug.Print ">"  str  "<"  ' now you can see what is comming through in the immediate window of VB
 Select Case (str) ' set a break point here so you can step through the case statement
   Case "A"
     Call LEDOn(vbRed)
   Case "B"
     Call LEDOn(vbGreen)
   Case "C"
     Call LEDOn(vbBlue)
   Case "D"
     Call LEDOn(vbYellow)
   Case Else
      Call LEDOff
 End Select
 
 'on the Arduino side just send out:

'Serial.println("A")

'why send out a whole line of text if you don't need it
192  Using Arduino / Interfacing w/ Software on the Computer / Re: interfacing the arduino to vb6 on: May 06, 2012, 09:16:24 pm
try this...
Code:
' set up the code for the input through MSComm1....

 str = MSComm1.Input  ' get the string
 str = Left(str,1)  ' chops off the first char and puts it back in str
 Debug.Print ">"  str  "<"  ' now you can see what is coming through in the immediate window of VB
 Select Case (str) ' set a "beak point " here in VB to stop the processing so you can step through the case
   Case "A"
     Call LEDOn(vbRed)
   Case "B"
     Call LEDOn(vbGreen)
   Case "C"
     Call LEDOn(vbBlue)
   Case "D"
     Call LEDOn(vbYellow)
   Case Else
      Call LEDOff
 End Select
 
' on the Arduino side just send out    Serial.println("A")

'why send out a whole line of text if you don't need it

193  Using Arduino / Motors, Mechanics, and Power / Re: foscam robot project on: May 06, 2012, 08:30:56 pm
how did you end up with a stepper if you wanted a two wire bipolar? Since you have the stepper you might as well use the well documented Arduino code to run it, or just buy a bipolar. There may be a way to run it using two wires, but I never saw any code to do it. It is designed to have the internal coils fire in sequence. Trying to make it a bipolar defeats what it was designed for ( precision positioning).
194  Using Arduino / General Electronics / Re: making my own h bridge on: May 02, 2012, 05:11:48 pm
Should work... pretty basic. I have built a number of these circuits for both motor control and also pulse width modulated power supplies. The funny thing is, it seems like the damn circuit always was somewhat aysmmetric. The transistors on one leg were always running hotter than the other. I always had to do some tweaking.

There are a lot of very cheap already made H-bridge chips and modules out there. You might look around on the net before you start building, unless you just want to give it a try.
195  Using Arduino / Project Guidance / Re: Arduino Water Controller on: May 02, 2012, 01:19:40 pm
You aught to make sure that the voltage drop is too much before you try anything else. If it is, it sounds like you have 24 V DC to work with, you could feed the signal from the Arduino  through a transistor hooked up to the 24 volt source. That should give you more than enough strength to drive a relay.
Pages: 1 ... 11 12 [13] 14 15