CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account

March 23, 2009 by robert Leave a Comment

Mail Light – Part 4 – Rotary Lights

The Mail Light hardware could easily be modified to turn on some rotary warning lights, such as these lights from Woot.com.

The example pictures below show the modification of a set of these lights to be driven by a U401 which works just as well as the U421:

wootlight1

Inside the lights:

wootlight2

Modifications to drive the LED and motor on their own:

wootlight3

Light attached to a development board that contains a U401:

wootlight4

U401 and driver wired up to operate the rotary light:

wootlight5

Filed Under: Uncategorized Tagged With: email, LED, output, programming, REALbasic, u401, uln2803

March 22, 2009 by robert Leave a Comment

Mail Light – Part 3 – Software

In this, the third part of the Mail Light project, I describe how the core routines were implemented. The core routines revolve around a timer that flashed the LEDs, four timers that check for email at a certain rate, and the REALbasic objects that manage the pop connection.

mainwindowmed1

mounted2

The simplest component is the timer that goes out to get mail every couple of minutes. There is a timer for each of the four mail accounts. When the timer times out, it simply calls the pop3 object and tells it to connect:

timer0

After the connection is established, the pop3 object prints that status in the first status box. After it connects, then a login is attempted. When the login is successful, the number of messages that are on the server is counted:

popsocket1

The pop3 object counts the number of messages on the server and displays that number. If the number is 0, then a boolean variable is set to false. If there is 1 or more messages, then that variable is set. That variable determines that the LED will be blinking. After counting the number of messages, the pop3 object disconnects and clears the status text:

popsocket2

The timer that checks for mail doesn’t run until the connection is made for the fist time with the press of the connect button. When the button is pushed, the server, user name, and other data is passed to the pop3 object and a connection invoked. The timer is started (for next email checking time) and the button is changed from a connect button to a disconnect button:

maillightswindowcontrolconnect1

If that same button is clicked after it has been toggled to be a disconnect button, then the pop3 object is disconnected from the server (if still connected), the timer is turned off, status cleared, the LED blinking is disabled, and the button again becomes a connect button:

maillightswindowcontrolconnect2

This isn’t an email program – you don’t get to read the email that you have with this program – you are just notified that you have email waiting on your server. After you are notified that you have email, you would go get those emails with your email program. The LED will likely still be blinking after you get the email with the other program. Clicking the button to disconnect and reconnect will start another check and discover that your email had been cleared.

The LED blinking routine is actually the longest of all of these functions. When the blink timer times out, the USBmicro DLL stuff is defined. The value for the LED port of the U421 (port A) is set to 0 before accumulating the status of the email accounts:

blinktimer1

The blink timer toggles the graphic indicator (and eventually the LED) on and off every other time that the timer times out. A boolean variable is flipped from true to false every other time. When false, the indicator is off. When true the indicator is on if there has been a message detected. And if the indicator is on, then LEDval is set to turn on a bit for turning on a specific LED:

blinktimer2

The first LED on the front and the first LED on the back are turned on with the value of &H11. The 2nd LEDs with the value of &H22, the third with a value of &H44, the 4th with &H88.

Once these values are all combined, then the value is sent to port A ov the U421:

blinktimer3

Download the REALbasic project and the executable code: MailLights Project and program.

To set this up for your email, edit the maildata.txt file to include your four (or fewer) email settings. When you run the program, these settings are loaded. You can leave the password as a blank line if you don’t like having a password in this file.

Click connect on all of the accounts that you will use to start the mail checking process. Click hide to hide the window to the tray icon. Recover the main window by double clicking on the tray icon.

When the program discovers an email in the accounts that it checks, the visual indicator will flash. If you have built the Mail Light hardware, then you will see flashing LEDS.

There is a lot of flexibility in the LEDs/lights that you can put together for this project. Originally I had planned to put a stack of ping pong balls on the top of my monitor to light up with some LEDs. This looked great in a dimly lit room and in the evening. But with my office window open, the ping pong balls just were not light enough against the open window to see from my lab.

Code could be changed to do more than just light LEDs. You could attach an LCD display to the U421 that would display, in text, the number of emails that are in each account. The U421 could directly drive a pair of seven-segment LED displays. You could use multiple U421 with a combination of hardware designs.

Enjoy this project. I have found that it is a very useful device just in the week that I have been using it on my PC. It will be a permanent part of my PC sertup now. If I make improvements to the code I will share it here. You are free to make improvements, suggest features, and port the code to other development environments. Or you can just build the hardware and use the software freely to drive your own Mail Light. Share pictures of your mail light and experiences building. 🙂

Filed Under: Uncategorized Tagged With: email, LED, programming, REALbasic, u421

March 21, 2009 by robert Leave a Comment

Mail Light – Part 2 – Software

In part one of this project I created hardware for the Mail Light. The idea behind the Mail Light project is to indicate the presence of emails that are currently on my email server with a flashing LED. This software runs on my PC and drives the hardware I created featured in the last post.

mainwindow

The REALbasic development environment REAL Software is used for this development since it made the email code (pop protocol) very easy.

The goal of the software that I created was to connect to four different email accounts and monitor them for the presence of email. If email was found, a specific LED associated with that account should blink. The LED blinking rate should be changeable, the rate at which the email accounts are polled should be changeable, and the program should hide as a tray icon until needed.

Each of the four accounts has a quarter of the main window with a few text areas for account information. The quarter is pictured below.

quarter-window

Each account has a connect button for enabling that account. When connected, the email account is scanned for email. To the right of the connect button is a visual indicator that will blink in unison with the LED. To the right of that is a text field that shows the number of messages that are on the server of that account.

The box marked “server” should contain the server address. Something like “pop.flintstone.com”. This would need to be the right server for your email account. Below that is the name that you use to log in to your account. It might be “fred” or it might need to be “fred@flintstone.com”. Under that is the box for your password. It is a field that shows up as asterisks. My password happens to be: ******* 🙂

Under the password field is a box that contains the rate, in minutes, that the email address is queried. Below that are two connection status boxes.

The other three email addresses are repeated.

To the lower right of the main window there is a box for the blink rate in 1/100 of a second. A value of 50 is a 1/2 second blink rate. Above that is a button to exit the program.

On the upper right of the main window is a button to hide the main window. A double-click on the program’s tray icon will expose this main window again. Everything keeps running with the main window hidden.

When the program is run, it needs to build up a tray icon and set that tray icon to a graphic (in this case called cg4) that is included with the project:

maillightsopen1

When the program is closed, that icon needs to be removed from the tray:

maillightsclose

The app tray object itself has only the task of making the main window visible when the user double-clicks on the tray icon:

apptray

The hide button on the main window just makes the main window not visible:

hidebutton

When the main form is made visible for the first time that the program is run, the U421 USB interface is discovered and the defaults for the program are loaded. Communication with the U421 is done through a DLL that is opened by REALbasic when the function inside that DLL is defined. The code first declares the three functions needed (and creates a return value for the function call) before using the functions:

maillightswindowopen1

USBm_FindDevices is the first call to USBm.dll. It searches the PC’s USB bus for U401 and U421 devices. In this simplified example code the true/false return code is not used. Non example code would want to process the return values for error. Port A of the U421 is set to output with this call: USBm_DirectionA(0, &HFF, &HFF). The 0 assumes that there is only 1 (indexed to 0) USBmicro device on the bus. If there were more, then additional code would be necessary to address the correct device. See the USBmicro information in the On-line Development Notebook (ODN) for all of the port direction command information.

Once the direction is set to output, all lines are turned off (0) to disable the LEDs:

maillightswindowopen2

After that a file called “maildata.txt” in the same folder/directory as the executable maillight.exe is searched for. Again, in a program other than example code, more code should exist to handle errors such as the file not being found.

The file contains text information that is read into the text boxes in the main window. The first line of the file should contain the server name for Email 1, the second line should have the user name, etc. The last line has the LED blink rate. The comments in the code show the format:

maillightswindowopen3

The file is opened and each line read into appropriate text boxes:

maillightswindowopen4

The LED blink rate is the last of the edit field elements that are loaded on startup by loading this file. Changing the values in the text fields after the file is loaded is also possible by editing those boxes.

Four mail-checking timers, four pop email objects, and the operation of the program will be described in part three of this project.

Filed Under: Uncategorized Tagged With: email, output, programming, REALbasic, u421

  • 1
  • 2
  • Next Page »

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2023 · Generate Pro Theme on Genesis Framework · WordPress · Log in