Iterating through open MDIChild forms

I recently had cause to check whether I already had an instance of an MDIChild form open in VB.NET. Using Array.Exists on the MDIChildren property of the MDI Parent form seemed like an elegant way to go. However, after further investigation it looked like i’d need code some supporting functions for the predicate. What I went with in the end was this:

 Dim formName As String = ""     ' Enter form name here
 
 For Each f As Form In Application.OpenForms
   If f.IsMdiChild = True AndAlso f.Name = formName Then
 
      ' Yes, we have a MDI Child form open with the required name
 
   End If
 Next

Here’s the complete code to open a new form, or activate the existing form (if there is one) :

 Dim formName As String = ""    Enter form name here
 Dim openForm As Form = Nothing
 
 ' Iterate and check for instance
 For Each f As Form In Application.OpenForms
    If f.IsMdiChild = True AndAlso f.Name = formName Then
       openForm = f
    End If
 Next
 
 openForm = CType(IIf(openForm Is Nothing, New OrderForm(New Guid(formName)), openForm), Form)
 openForm.MdiParent = Me
 openForm.Show()
 openForm.Activate()

DMX Lighting Project

DMX Lighting

I came across some RGB LED’s the other day on oomlout (http://www.oomlout.co.uk/5mm-rgb-leds-super-flux-x3-p-203.html) and wondered what I could create with them. Having been a light jock in the past I decided I’d like to create my own little lighting show (to be possibly used as part of a larger project in around 12 months time… watch this space). I secured 12 for the price of £9.72 including delivery and they turned up within a couple of days.

I quickly set to work mounting them on their own little PCB with current limiting resistors & header.

From RGB / DMX Lighting Project

The plan is to drive them with an Arduino, MAX485 receiver to handle DMX interface duties & PWM Shield (from Practical Maker : http://www.practicalmaker.com). Here’s the test code to check the LED’s, and my soldering skills. Notice i’m using PWM pins 9,10 & 11 for each colour:

int redLedPin = 11;
int greenLedPin = 10;
int blueLedPin  = 9;  
 
void setup()  {
} 
 
void loop()  { 
 
  // All values are inverted. We'll need to deal with this later on.
 
    // Red
      analogWrite(redLedPin, 1);
      analogWrite(greenLedPin, 255);
      analogWrite(blueLedPin, 255);
      delay(300);                            
 
    // Green
      analogWrite(redLedPin, 255);
      analogWrite(greenLedPin, 1);
      analogWrite(blueLedPin, 255);
      delay(300);     
 
    // Blue
      analogWrite(redLedPin, 255);
      analogWrite(greenLedPin, 255);
      analogWrite(blueLedPin, 1);
      delay(300);       
 
}

Here’s a quick video of the test in action. You can tell that the LED is quite bright, as it’s saturating the image.

 

Here’s some slow shutter pics I took of the LED in action:

 

From RGB / DMX Lighting Project
From RGB / DMX Lighting Project

I think the next stage is to encase the PCB’s in either hot melt glue or sillicone sealant, to afford them a little protection. Next up will be testing with the PWM shield, as soon as it turns up.

I’ll be using Q Light Controller (http://sourceforge.net/projects/qlc/), and an Enttec Open DMX USB Interface (http://www.enttec.com/index.php?main_menu=Products&pn=70303&show=description) to control my little show.

 

Update 09-11-2011:

I covered the top and bottom of the PCB’s with hot melt glue. It’s not perfect, but I’m not going for IP68 😉

From Instant Upload

 

Update 17-11-2011:

The MAX485 Transceiver chips arrived – in a GIANT box I might add – so I got busy soldering them into a piece of stripboard (that was a little oversized…) and wired them to the Arduino PCB. With a little code, and help, from http://blog.wingedvictorydesign.com/2009/03/20/receive-dmx-512-with-an-arduino/, I got the second part of the project up and running, namely receiving DMX. At the moment I’m just outputting to the serial console . But eventually the DMX values will be piped along to the LED’s via the PWM Shield, as and when it turns up.

As the code from the blog above has been released under the WTFPL license (yeah, I had to look it up: http://sam.zoy.org/wtfpl/) I’ll be posting the finished code, but at this moment in time it’s pretty pointless due to the fact that I haven’t changed much from the original source.

Thanks to Max Pierson of Winged Victory Design for the help here – go visit his site, it’s been pretty useful for my project www.wingedvictorydesign.com

1 2 3 4