A Professional Manufacturer of Smart Interactive Screens For More Than 10 Years
Arduino for wireless control-
Power message board!
This is a simple project to create a wireless programmable message board.
It uses the XBee module to provide a wireless serial link between your computer and your device.
You interact with it through a simple menu system.
No button (
This is hidden except the reset button)on the device.
Arduino has three types of memory: Flash memory, EEPROM, and RAM.
In this project, we use these three to store messages and values.
Since we can't change flash from inside the program, we use it to store "can" messages or messages that don't change.
We put these short so they fit on the display.
We can also use RAM to store information but we don't have much information so we keep it short as well.
The internal EEPROM is only 512 bytes, but this is enough to store a program that can show which blocked messages and how long.
Finally, we added an external serial memory in which a long message was stored (
Up to full-size EEPROM)
We scroll on the display.
The following programming concepts are demonstrated :-
Create a simple menu system using a serial interface-
Accept and verify strings and integers via serial interface-
Retrieve strings from flash memory using progmem-
Storing and retrieving strings in an external EEPROM using a simple data structure-
Store configuration data in on-board EEPROM-
Display static and scrolling text on the parallel interface LCD (
Or LCD compatible display)-
In this case, a analog value is measured and the photoelectric flat Code: three things must be done by the program.
First, it has to write the data to the display in one of two ways-
Direct or scroll.
While doing so, once the serial data appears on the serial input, it must be ready to jump to the user menu routine.
Finally, the program must be on-
External serial memory.
Hardware: The hardware must be Arduino-
Compatible, supports XBee that does not have much soldering, and has some prototype board space to accommodate the interface of the display, serial EEPROM, and LDR.
I want it to be easy
The ready crystal library, so I chose an LCD-
Compatible with VFD character display.
For Arduino, I chose the Arduino Pro 328 5 V for Sparkfun. -It's cheap-
It is with Sparkfun Xbee shield (
More information about this)-
It doesn't have a USB and I don't need it once it's initially programmed * it has 5 v installed on 3.
3 v pin, could be a problem
However, Sparfun Xbee shield has its own TTL level converter and 3.
3 v regulator for Xbee, I chose the standard power supply, Series I XBee unit.
They seem to have enough scope of application.
No more complex Series II features are required for this project.
In order to install Xbee, I chose the Xbee shield of Sparkfun. -
Expensive but convenient
It has only enough prototype board space and it will not separate all the pins.
I was able to weld to the pins, but this could be a problem during my work and I also purchased a Sparkfun Xbee USB carrier.
You need it to connect Xbee to your computer.
The VFD selected is Noritake cuvault ecpb-W1J. -
It's cheap on eBay. It is LCD-
Compatible * it attracts a lot of power400 ma at 5v.
The serial EEPROM is the 24lc2016 256 k eeprom from the micro-chip. -It's cheap-
It is a I2C part so only two pins are needed
It is supported by wires.
The power supply is a 9 v Wall, easy to usewart.
Xbee and Arduino handle their own voltage regulation while the monitor is 7850-
Based on a linear regulator.
It dropped 4 v at 400ma and dissipated a lot of heat in doing so.
In hindsight, the better option should be the wall connector for the external 5 v switch mode.
Finally, for this case. . .
A wooden cigar box.
Easy to use, good fit and finish, and cheap --$3.
Here is the code for the project.
A large part of this is the use of serial menu routines and progmem instructions to store strings in flash memory.
I originally wrote it to remind my children of their chores.
You can change the strings according to your needs.
Initially I just took my serial menu response as serial.
Println command, but it is stored in valuable RAM.
On the contrary, I have
Code that uses PSTR is written so that the string is still in the code, but is stored in FLASH at compile time.
You can use the typical PROGMEM scheme for multiple arrays, but this makes it difficult for the code to follow.
I used the example here, which defines an extension that allows PSTR to work in the same function as Serial.
Println, only a pointer to prog_uchar instead of char.
The following figure shows the connections to be made in the prototype board area.
The connection between ATMEGA and XBee is not shown because XBee shields handle them.
If you don't use a shield, you need to use your own level converter between ATMEGA and XBee, and 3.
3 v regulator for XBee.
De-coupling capacitors and other passive components are also assumed.
Transistor pull
The downlink for XBee programming/reset can be seen on my motherboard, but not included here.
If you want to build your own 7805-
Based on the regulator, it is just a regulator and a few capacitors.
You can easily find the schematic diagram online.
If you are going to use the VFD like I do, I would suggest using the regulated 5 v switch mode wall adapter instead of the linear regulator.
7805 is OK if you use a normal LCD, and you don't even need a radiator.
The linear regulator also has a better option if you are willing to pay more.
Some forward voltage is reduced to 0. 5v.
If you want to use a PCB-
Install the power jack on the prototype board and make sure to purchase a power jack with a standard of 0. 1" spaced pins.
The more common style has larger spades, which are stronger but do not work on the prototype board.
In the next steps, I will introduce some code that may be useful to Arduino programmers who have just started.
Serial input polling: this is easy. Serial. available()is non-
Zero when there is data to read.
When we want to stop
Between messages, we're just polling Serial. available()
Cycle over and over for a while.
We will break the loop if anything happens:/at messagespreviusmillis = millis (); while (millis()-
0){breakout = 1;
/Interruption delay loop interruption; }}if (breakout == 1){breakout = 0;
/Interrupt the Loop Interrupt of the message program; }
It does what it says.
Clear the screen and send the cursor to the home page.
Note that the Arduino serial monitor is not a real terminal.
It does not support the control characters required to work.
You need to use a real terminal emulator program in this project.
/Function clearAndHome ()
/Clear the terminal screen and send the cursor homevoid clearAndHome (){Serial. print(27, BYTE); // ESCSerial. print("[2J");
/Clear screen sequence. print(27, BYTE); // ESCSerial. print("[H");
/Cursor to home}
How can multiple types of data be stored in the internal EEPROM when only bytes can be written?
I need to store the index of the message array and the display time.
The easiest solution is to store one at an odd address and another at an even address.
I won't paste the code here, but it has a good record in the source code.
More complex data structures, such as strings, need to be considered more when processing bytes.
The easiest way for me to display strings on the next page.
There are also libraries that allow you to store complex data types in the EEPROM.
With the standard Arduino library, you can only write and read bytes where you go back and forth to the EEPROM.
So, how do you handle strings?
Remember, in C/C (
And other languages)
The string is the number of characters terminated by "\ 0.
So just write the character to the EEPROM in bytes and end with "\ 0.
You can keep it until you are bored or almost out of EEPROM space.
I keep the last two addresses so I can do it in "\ 0" and ctrl-
D. I use it to mark the end of the text.
I decided to split the input into 200-
The string entered by the user is not considered.
This is because I wasn't sure at first how I was going to handle these strings, so I buffered them in an array of 200 characters while reading them.
To read a character from the EEPROM into the array, I read a character from the array at X position and X 1 position, staring at address 0.
If X 1 is not "\ 0" or ctrl-
D, I store character X in the array.
I use pointer arithmetic to move along the array and unreference the pointer used to store and get the data.
You can search for X "\ 0" in the EEPROM address space if you want, maybe there will be a random message, or let the user choose one.
I just read it from beginning to end.
The only thing I use the string function is "wear-
"Flat" on VFD"
The string scrolls alternately along the top and bottom rows shown.
Noritake LCD-
The compatible vfd I selected supports 4 brightness levels-
100%, 75%, 50% and 25%.
In the brightest environment, the display is very bright and will look conspicuous in the dark room.
I connected an LDR with a 10 k resistor to form a voltage divider.
The voltage of this change is read at pin a0.
I update the brightness of each new string.
You can certainly do so often, if you like.
Here is the brightness setting function:/function setdisplay bright ()
/Set the brightness of the Noritake LCD-
Compatible vfd based on ambient light level/need to customize LCD library with LCD. vfdDim()
Use ldrread and LDRpin as global empty setdisplay bright (){
LDRreading = analogRead (LDRpin); if (
800){lcd. vfdDim(0); }else if ((
= 800)&& (
450)){lcd. vfdDim(1); }else if ((
= 450)&& (
200)){lcd. vfdDim(2); }else{lcd. vfdDim(3); }// Serial. println(LDRreading); return; }What's lcd. vfdDIm()?
This is a feature I added in my local copy of the LiquidCrystal Library.
Here's how to add it: edit the following library files under the LiquidCrystal library Directory.
Note that ">" comes from diff and it shows the difference between it and the original version of LiquidCrystal.
Cpp: 255,270 d254