Let's Make Robots!

Computer GUI to Control Arduino/Adafruit

Ok, it's time to face facts..., I'm no programmer.

I'm building a spectrograph for my 36" telescope and since this device could be 13 feet in the air I'd like to remotely control it. I've built the Adafruit Motor Shield and have attached it to my Arduino board. I'm hoping there is a path to create a GUI with buttons I can mouse-click on that will activate a relay to turn the power to one of two calibration lamps, argon and neon, slowly turn three reversible DC motors that will be geared to two micrometer stages and rotate a 200mm camera lens focus, plus, while I was planning on a fourth DC motor to rotate in a mirror to divert the calibration light into the device but I think it may be better to use a servo there to slowly go from 0 to 180 to bring that optic in and back again. I know Arduino can control 4 DC motors and I think it can do 3 DC's and 1 Servo.

The computer on the telescope, that'll control the spectrograph, is part of an adhoc network where I remote desktop control it from 20 feet away.

A description of what I'd like is;
GUI buttons within a frame to; turn on the lamps via relay activation (I may need to add a Light Dependent Resistor so Arduino can determine that the lamps actually lit which then may require an indicator light within the GUI frame), buttons to rotate each of the DC motors slowly (PMW?) reversibly, and a button that would slowly rotate the servo to 180 and slowly back again when its button is clicked again.

The spectrograph will have two CCD cameras for me to see visually something that indicates the motors have turned or optic rotated in.

I know what I need. I have an idea how it's all supposed to work. I'm good at mechanical, electronics and optics but some pieces (coding) elude me. Is there anyone who could design the code to make a computer GUI that looks like the attached picture with described buttons?

I hope there is....

Thanks, Steven

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

...now that's cool....

So this code could be altered for another project to, for instance, create a different worded button, of a different shape if need be, that when pointed to an Output pin of MEGA (Uno too?) would activate a motor if pressed, or change the color of the button if an input were found to be high?  And is capable of Save-As with any changes for that other project?

The only thing that didn't at first appear compatible in the YouTube video was the slider bars as you described them.  The hardware to move a motor would be set up with two relays, one for direction and the second to jog it in the direction chosen.  This made it intuitive when using the Firmata_Test derivitive code picture I attached recently and the button would change text In to Out when it was pressed and then the second botton made moved the motor move changing text from Stop to Start until is was clicked again to then read Stop.  There is a linear slide pot whose wiper is attached to the moving part associated with that motor and therefore it sends a variable voltage within the range of 0-5VDC to the analog input on MEGA and at the limits of travel there are dual throw switches that break the circuit to stop the motor in that direction and send 5VDC to an input on MEGA indicating limit reached.  The other motor direction is then the only option until the made limit switch is unmade.  That slide pot voltage is on an input and should be displayed as a bar graph of some sort giving some indication of where between the limits it is.  Again, the project as it was moving forward was made compatible with Firmata_Test and possibly something I could understand to create something for the next project.

Three motors would be set up this way with the fourth, the calibration mirror motor, not needing a slide pot because it will be in or out and never inbetween.  The calibration mirror motor would stop when its limit switch is reached sending that 5VDC to a MEGA input via the dual throw.

The Neon or Argon lamps are also set up on two relays, one is for choice and the other is to supply 120VAC to the chosen lamp.  The way it appears in the video is great as it has choice and on/off!

I'll try to attach two pictures.  The first is the motor wiring integrating limits that stop the motor and send to inputs.  The second is the diagram of the system, showing the cable supplying power to the lamp calibration box and within it is also the voltage converters needed for the spectrograph box containing the circuit board of relays/transistors and MEGA.  The one is bolted to the other and amphenol conectors are used.  You'll see the Grating Rotation was without limits, highlighted in red, and that was due to use of Uno.  MEGA provides enough pins now and this Excel file has not been updated due to not knowing if the project mechanics would get code.  All the parts except those within the bolded box labelled Spectrograph are done and the circuit board of relays/transistors is also done, just not the special order parts.

You can change the wording of the buttons. You can change the shape, as long as it has 4 sides and 2 pairs are parallel to one another. I believe buttons could be given a shape, but, the shape would be due to an image, and, not actually be a different shape.

To explain, you might be able to use an image of a circle as the cover for a button. The actual button outline will still be square, but, what the user would see would be a circle. It would take a good bit more programming to make it work.

My thinking on the sliders is this, the slider will denote the position of the affected component. Since the computer will know where they are, moving the slider means the computer can tell them where to go. Hence, a slider moved to a particular position will both show where an object is, and, where it should move to. The control would all be in the programming. If the arduino is expecting specific outputs to tell it when and where to move, it can still receive them. But, if you really want buttons and scales. I can give that to you too.

It would seem that for the mirror object I could either leave the slider, and, it will show you where in the cycle between In/Out it is, or, I can add a couple buttons, and let the scale show you where it is, or, I can lose the scale, and just have a pair of buttons.

Color changing on command is no problem.

Ahhh, I see.


Yes, I may need the slider to only be a representation of approximately where within the limit switch range it is based upon the voltage seen on the wiper; 0VDC<x<5.0VDC.  To explain why, if I move the 36" diameter primary mirror in or out slightly in the collimation process of lining up all the optics, that forward or backwards movement then changes where the cone of light is within the range of the linear stage holding the slit, and the slit must be put at the cone point.  I'll have the guiding CCD camera focused on the slit's reflection (only the target starlight goes through the slit and starlight around the target is used for autoguiding or the remnent target stars light that couldn't fit in the slit), so too if the stars are fuzzy because the cone moved I will need to move the linear bearing stage to a new position, at focus, and this becomes the new '0'.  If I were to see the slider value continue to creep up because collimation is a critical thing, then I'd remember next time to back the adjuster screws out, to bring the focus closer to the mid-point of the stage travel and the attached wiper.

There would be less of that type of movement for the rotational stage slider, minus the tangent error of a linear slider, but so too I'll be viewing a pattern of brighter and dimmer lines of the Neon and Argon calibration light spectrum and determining the starting and ending wavelength seen on the main CCD camera, rotating the stage to get the right segment into view (I won't be able to see frmo blue to red, only about 344 Angstroms.  If the lines happen to be blurry, the motor rotating the camera lens focusing the spectrum onto the main CCD is will be used to make it sharp.

For all aspects of setting up the system there's a visual cue I will use to make appropriate adjustments, button clicks, except the calibration light mirror being entirely in the out position.  Where as the 'in' position shows me the calibration light spectrum on the main CCD camera I would definately need to see the 'out' limit switch made.  A slider is not needed there....

If it looked like this picture and worked I'd be dancing....


This is no April Fools joke. It just so happens I am updating this today. :) 

...that would have been cruel.  It looks amazing! :D  I've just notified the wife that lit looks like I'll be spending some money on a slit, lenses, and the 1800 lines per millimeter grating..., now that some code really appears to be on the horizon.  They up until now haven't been purchased because they are non-refundable and have very little value on the used market.  The 8" guidescope was just mounted on the 36" a couple weeks ago which will allow me to, with an auotoguider camera, verify the stability and accuracy of the scope's tracking, with a goal of keeping a 30-50 micron star in a 35 micron wide slit.  The spectrograph will do it not through the C8 scope but rather with the reflected light off the slit's backside (what doesn't go through the slit), but I'll get an idea of the magnitude of work to get the scope to the tracking level needed.

Wow, thanks again....



Let me know if there are any changes you would like me to make, or, if there is something you would like me to explain better. I can tell you that the button choices are not currently saved. I will be sure to set the program up to read the potentiometers before anything else happens. The drop down for Calibration Lamp Type is disabled. I don't understand how you need to set a pin for that particular label.


The lamp power and selection are each on separate relays.  The power is the easy one, the power, 120VAC, is on the NO contact so power is sent to one of two lamps on the second relay only when the power relay is energized.  The two lamps are on relay 2 and on the same pole but different throw directions; NC contact is Neon, and NO is Argon.  So when NO contact is held closed the Argon will light as long as Power relay button is pressed.  Each lamp has photoresistors currently wired to Arduino Analog Input pins.


Can the slide bars, if they are that length, get a number included to the right of the slide to show the rough position like 0 to 1000 (or something)?


My gosh, I can choose the I/O pin, save the I/O configuration (though I may have to re-choose the Com Port that's ok), and it will come up with the same button names after rading the limit switch states and pot wipers?  And I can do a Save-As with whatever name I want (or does that require that I recompile?), and, if I'm clever I can rename buttons for some future robot board project as long as it's MEGA (and again recompile?)?  How would I, for instance, change it from Telescope GUI to something else?

This is sooooo cool.


http://pastebin.com/5tQUeTwY This link is set to expire in a month.
zip containing everything you "should" need https://dl.dropbox.com/u/28951892/Telescope%20GUI.zip except for
Python http://www.python.org/download/ 2.7.3
and, PySerial for the version (x86 or 64bit and 2.7) that you download from above http://www.lfd.uci.edu/~gohlke/pythonlibs/ (near the bottom 1/3 of the page)

Re: sliders. There is in fact code that will add numbers to the right of the sliders as they are updated.

I still have a fair bit of code that will get the program to talk to the arduino. I have one that I can use to test bits of code to get everything hopefully working.

Re: the Calibration Lamp - Type. I was mistakenly thinking this choice would need two pins. It does not. A single pin with output will be either Neon, or, Argon. The power pin above will control whether or not the lamp is turned on. A NOT gate will be required on the arduino end of this setup to make all of this work, then, the pins for Neon and Argon will have the responses from the photoresistors. Bottom line, I will reenable that pin selector.

Thanks, I've downloaded everything and I'll try to install it.

Regarding the lamps, it's 2-relay (2-button) configuration is the same as any of the motor 2-button.  The calibration lamp box already works with Arduino Uno using the Firmata_Test.  For the lamps, 2 output pins are used going to one of two relays.  They should make a button change to Off/On when de-energizede/Energized by the Arduino Output Pin.  The second Arduino Output Pin, same thing; output Off is set to NC contact on relay and energizing the lamp type Output Pin then closes the Contact enabling Argon.


0 - 0 =Off-Neon; No light comes on, so no detection on Input Pin with photoresistor so Power Button shows Off and Neon Button stays showing Off.

0 - 1 =Off-Argon; No light comes on, so no detection on Input Pin with photoresistor so Power Button shows Off and Argon Button stays showing Off.

1 - 0 =On-Neon; Neon light turns on and Input Pin Neon goes high so Power Button shows On and Neon Button changes from Off to On.

1 - 1 =On-Argon; Argon light turns on and Input Pin goes high so Power Button shows On and Argon Button changes from Off to On.


I don't see a need to put an inverter on it, and really hope I don't have too....


I was thinking out loud again. :P I am trying to get this put together to your specs, so, I will attempt to learn to keep my opinions out of the setup. As I understand it now, The Neon pin, and, the Argon pin will be to read inputs from the phototransistor/photodiode to tell whether the Lamp is actually on, correct?