bascom avr tft lcd brands

Asia has long dominated the display module TFT LCD manufacturers’ scene. After all, most major display module manufacturers can be found in countries like China, South Korea, Japan, and India.

In this post, we’ll list down 7 best display module TFT LCD manufacturers in the USA. We’ll see why these companies deserve recognition as top players in the American display module industry.

STONE Technologies is a leading display module TFT LCD manufacturer in the world. The company is based in Beijing, China, and has been in operations since 2010. STONE quickly grew to become one of the most trusted display module manufacturers in 14 years.

Now, let’s move on to the list of the best display module manufacturers in the USA. These companies are your best picks if you need to find a display module TFT LCD manufacturer based in the United States:

Planar Systems is a digital display company headquartered in Hillsboro, Oregon. It specializes in providing digital display solutions such as LCD video walls and large format LCD displays.

Microtips Technology is a global electronics manufacturer based in Orlando, Florida. The company was established in 1990 and has grown into a strong fixture in the LCD industry.

What makes Microtips a great display module TFT LCD manufacturer in the USA lies in its close ties with all its customers. It does so by establishing a good rapport with its clients starting from the initial product discussions. Microtips manages to keep this exceptional rapport throughout the entire client relationship by:

Displaytech is an American display module TFT LCD manufacturer headquartered in Carlsbad, California. It was founded in 1989 and is part of several companies under the Seacomp group. The company specializes in manufacturing small to medium-sized LCD modules for various devices across all possible industries.

The company also manufactures embedded TFT devices, interface boards, and LCD development boards. Also, Displaytech offers design services for embedded products, display-based PCB assemblies, and turnkey products.

Displaytech makes it easy for clients to create their own customized LCD modules. There is a feature called Design Your Custom LCD Panel found on their site. Clients simply need to input their specifications such as their desired dimensions, LCD configuration, attributes, connector type, operating and storage temperature, and other pertinent information. Clients can then submit this form to Displaytech to get feedback, suggestions, and quotes.

A vast product range, good customization options, and responsive customer service – all these factors make Displaytech among the leading LCD manufacturers in the USA.

Products that Phoenix Display offers include standard, semi-custom, and fully-customized LCD modules. Specifically, these products comprise Phoenix Display’s offerings:

Clients flock to Phoenix Display because of their decades-long experience in the display manufacturing field. The company also combines its technical expertise with its competitive manufacturing capabilities to produce the best possible LCD products for its clients.

True Vision Displays is an American display module TFT LCD manufacturing company located at Cerritos, California. It specializes in LCD display solutions for special applications in modern industries. Most of their clients come from highly-demanding fields such as aerospace, defense, medical, and financial industries.

The company produces several types of TFT LCD products. Most of them are industrial-grade and comes in various resolution types such as VGA, QVGA, XGA, and SXGA. Clients may also select product enclosures for these modules.

All products feature high-bright LCD systems that come from the company’s proprietary low-power LED backlight technology. The modules and screens also come in ruggedized forms perfect for highly-demanding outdoor industrial use.

LXD Incorporated is among the earliest LCD manufacturers in the world. The company was founded in 1968 by James Fergason under the name International Liquid Xtal Company (ILIXCO). Its first headquarters was in Kent, Ohio. At present, LXD is based in Raleigh, North Carolina.

We’ve listed the top 7 display module TFT LCD manufacturers in the USA. All these companies may not be as well-known as other Asian manufacturers are, but they are equally competent and can deliver high-quality display products according to the client’s specifications. Contact any of them if you need a US-based manufacturer to service your display solutions needs.

We also briefly touched on STONE Technologies, another excellent LCD module manufacturer based in China. Consider partnering with STONE if you want top-of-the-line smart LCD products and you’re not necessarily looking for a US-based manufacturer. STONE will surely provide the right display solution for your needs anywhere you are on the globe.

bascom avr tft lcd brands

دستورات ویژه برای صفحه نمایش LCD, تراشه های I2C, صفحه کلید کامپیوتر, صفحه کلید ماتریسی, پذیرش RC5 و UART نرم افزاری, SPI, ال سی دی گرافیکی, ارسال IR RC5

bascom avr tft lcd brands

The book is intended for electronics professionals dealing with electronics professionally or amateurishly interested in the practical applications of microcontrollers from the AVR family. It will be especially helpful for those Readers who intend to write programs for AVR microcontrollers in one of the most convenient Bascom language programmers.

The book presents various, complete, exemplary projects, all implemented on microcontrollers from the AVR family. The author has prepared and made available on the Publishing House website complete documentation of all projects described in the book, including printed circuit boards.

bascom avr tft lcd brands

Thin film transistor liquid crystal display (TFT-LCD) is a variant of liquid crystal display (LCD) which uses thin-film transistor (TFT) technology to improve image quality (e.g., addressability, contrast).

TFT LCDs are used in television sets, computer monitors, mobile phones, handheld video game systems, personal digital assistants, navigation systems, projectors, etc.

sub procedure TFT_Set_Active(dim Set_Index_Ptr as ^TTFT_Set_Index_Ptr, dim Write_Command_Ptr as ^TTFT_Write_Command_Ptr, dim Write_Data_Ptr as ^TTFT_Write_Data_Ptr)

sub procedure TFT_Set_Brush(dim brush_enabled as byte, dim brush_color as word, dim gradient_enabled, gradient_orientation as byte, dim gradient_color_from, gradient_color_to as word)

bascom avr tft lcd brands

What is a computer? ................................................................................................................... 95 What does a computer system do? ............................................................................................. 95 What exactly is a microcontroller? ............................................................................................... 96 What does a microcontroller system do?..................................................................................... 97 What you do when learning to program ....................................................................................... 98 AVR microcontroller hardware .................................................................................................... 99 Power supplies............................................................................................................................ 99 BASCOM and AVR assignment ................................................................................................ 100 Programming words you need to be able to use correctly ......................................................... 102

11 Getting started with AVR Programming ........................................................................ 103 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8

Breadboard ............................................................................................................................... 103 Breadboard+Prototyping board circuit ....................................................................................... 104 Alternative ATTiny461 breadboard circuit.................................................................................. 106 Alternative ATMega48 breadboard circuit ................................................................................. 107 Alternative ATMega breadboard circuit ..................................................................................... 108 AVR circuit description .............................................................................................................. 109 Output Circuit - LED .................................................................................................................. 110 AVR programming cable ........................................................................................................... 110

12 Getting started with Bascom & AVR .............................................................................. 111 12.1 12.2 12.3 12.4 12.5 12.6 12.7

The compiler ............................................................................................................................. 111 The programmer ....................................................................................................................... 111 An introduction to flowcharts ..................................................................................................... 112 Bascom output commands ........................................................................................................ 113 Introducing ‘bugs’ to see what happens .................................................................................... 114 Getting started code for the ATMega48 .................................................................................... 115 Getting started code for the ATMega8535................................................................................. 116

Variables - numbers inside the AVR.......................................................................................... 134 Pedestrian crossing lights controller .......................................................................................... 135 Pedestrian Crossing Lights schematic ...................................................................................... 136 Pedestrian Crossing Lights PCB Layout.................................................................................... 137 Algorithm planning example – pedestrian crossing lights .......................................................... 138 Flowchart planning example – pedestrian crossing lights .......................................................... 139 Program example - pedestrian crossing lights ........................................................................... 140 Modification exercise for the pedestrian crossing ...................................................................... 141 Changing a variable – simple stepping/counting ....................................................................... 142 For-next tricks with flashing LEDs ......................................................................................... 144 For-Next ................................................................................................................................ 145 Using variables for data......................................................................................................... 147 Types of memory .................................................................................................................. 147 Binary and Hexadecimal numbers ......................................................................................... 148 Learning to count in binary .................................................................................................... 149 Learning some Hexadecimal (HEX) ...................................................................................... 150 Rules about variables ............................................................................................................ 153 a few examples of variables in use ........................................................................................ 153 Random Numbers ................................................................................................................. 154 The Bascom-AVR simulator .................................................................................................. 155 Variables research assignment ............................................................................................. 157 Byte variable limitations......................................................................................................... 158 Electronic dice project ........................................................................................................... 159 Programming using variables – dice...................................................................................... 159 Dice layout stage 1................................................................................................................ 160 Dice layout stage 2................................................................................................................ 161 Dice Layout final.................................................................................................................... 162 First Dice Program flowchart ................................................................................................. 163 A note about the Bascom Rnd command .............................................................................. 164 Modified dice ......................................................................................................................... 165 Multiple LEDs - 7 segment displays....................................................................................... 167 Programming using variables - sound ................................................................................... 173 Make a simple siren .............................................................................................................. 175 Quiz Game Controller............................................................................................................ 177 Quiz game controller system context diagram ....................................................................... 177 Quiz game controller block diagram ...................................................................................... 178 Quiz game controller Algorithm ............................................................................................. 179 Quiz game schematic ............................................................................................................ 180 Quiz game board veroboard layout ....................................................................................... 181 Quiz Controller flowchart ....................................................................................................... 186 "Quiz Controller program code ............................................................................................... 187

31 LCDs (liquid crystal displays) ......................................................................................... 264 31.1 Alphanumeric LCDs .................................................................................................................. 265 ATTINY26 Development PCB with LCD ............................................................................................... 266 31.2 Completing the wiring for the LCD............................................................................................. 268 31.3 LCD Contrast Control ................................................................................................................ 269 31.4 Learning to use the LCD ........................................................................................................... 270 31.5 Adding more interfaces to the ATTiny26 Development board.................................................... 271 31.6 Ohms law in action – a multicoloured LED ................................................................................ 273 31.7 Repetition again - the ‘For-Next’ and the LCD ........................................................................... 275 31.8 Defining your own LCD characters ............................................................................................ 276 31.9 LCD custom character program ................................................................................................ 276 31.10 To CLS or not to CLS that is the question ............................................................................. 278 31.11 A simple digital clock ............................................................................................................. 279

Strings assignment ................................................................................................................... 296 ASCII Assignment ..................................................................................................................... 298 Time in a string ......................................................................................................................... 301 Scrolling message assignment .................................................................................................. 303 Some LCD programming exercises........................................................................................... 304

Microcontroller power limitations ............................................................................................... 305 Power ....................................................................................................................................... 307 Power dissipation in resistors .................................................................................................... 307 Diode characteristics ................................................................................................................. 308 Using Zener diodes ................................................................................................................... 309 How diodes work....................................................................................................................... 310 How does a LED give off light? ................................................................................................. 311 LCD Backlight Data ................................................................................................................... 312 Transistors as power switches .................................................................................................. 313 High power loads .................................................................................................................. 314 AVR Power matters............................................................................................................... 314 Darlington transistors - high power ........................................................................................ 316 ULN2803 Octal Darlington Driver .......................................................................................... 318 Connecting a FET backlight control to your microcontroller ................................................... 320 FET backlight control ............................................................................................................ 321

ADC - Analog to Digital conversion ........................................................................................... 344 Light level sensing .................................................................................................................... 344 Voltage dividers review ............................................................................................................. 345 AVR ADC connections .............................................................................................................. 345 Select-Case .............................................................................................................................. 346 Reading an LDR’s values .......................................................................................................... 348 Marcus’ Nightlight project .......................................................................................................... 350 Temperature measurement using the LM35 .............................................................................. 353 A simple temperature display .................................................................................................... 354 LM35 temperature display ..................................................................................................... 357 Voltage measurement using a voltage divider ....................................................................... 360 Variable power supply voltmeter program ............................................................................. 362 Force Sensitive Resistors ...................................................................................................... 364 Piezo sensor ......................................................................................................................... 364 Multiple switches and ADC .................................................................................................... 365

H-Bridge.................................................................................................................................... 373 H-Bridge Braking....................................................................................................................... 375 L293D H-Bridge IC .................................................................................................................... 376 L298 H-Bridge IC .................................................................................................................... 378 LMD18200 H-Bridge IC ............................................................................................................. 379 LMD18200 program .................................................................................................................. 382 Darlington H-Bridge .................................................................................................................. 383 Stepper motors ......................................................................................................................... 386 PWM - pulse width modulation .................................................................................................. 393 PWM outputs ........................................................................................................................ 394 Uses for PWM ....................................................................................................................... 395 ATMEL AVRs PWM pins ....................................................................................................... 396 PWM on any port .................................................................................................................. 397 PWM internals ....................................................................................................................... 398

40 AVR pull-up resistors ...................................................................................................... 400 41 Keypad interfacing........................................................................................................... 401 41.1 41.2 41.3 41.4 41.5 41.6

Analogue seconds display on an LCD ....................................................................................... 426 LCD big digits ........................................................................................................................... 429

Simplex and duplex ................................................................................................................... 499 Synchronous and asynchronous ............................................................................................... 499 Serial communications, Bascom and the AVR .......................................................................... 500 RS232 serial communications ................................................................................................... 501 Build your own RS232 buffer..................................................................................................... 503 Talking to an AVR from Windows XP ........................................................................................ 504 Talking to an AVR from Win7 .................................................................................................... 506 First Bascom RS-232 program .................................................................................................. 508 Receiving text from a PC .......................................................................................................... 509 BASCOM serial commands ................................................................................................... 510 Serial IO using Inkey() ........................................................................................................... 511 Creating your own software to communicate with the AVR ................................................... 514 Microsoft Visual Basic 2008 Express Edition ......................................................................... 515 Stage 1 – GUI creation .......................................................................................................... 516 Stage 2 – Coding and understanding event programming ..................................................... 525 Microsoft Visual C# commport application ............................................................................. 530 Microcontroller with serial IO. ................................................................................................ 535 PC software (C#) to communicate with the AVR ................................................................... 540 Using excel to capture serial data ......................................................................................... 544 PLX-DAQ .............................................................................................................................. 546 StampPlot ............................................................................................................................. 547 Serial to parallel .................................................................................................................... 549 Keyboard interfacing – synchronous serial data ........................................................................ 554 Keyboard as asynchronous data ............................................................................................... 561

56 Amplifier ........................................................................................................................... 608 57 Bike audio amplifier project ............................................................................................ 608 58 Graphics LCDs ................................................................................................................. 614 58.1 58.2 58.3

The T6963 controller ................................................................................................................. 614 Graphics LCD (128x64) – KS0108 ............................................................................................ 619 Generating a negative supply for a graphics LCD ..................................................................... 624

59 GLCD Temperature Tracking Project ............................................................................. 626 59.1 59.2 59.3 59.4 59.5 59.6 59.7

Low level languages:................................................................................................................. 638 AVR Internals – how the microcontroller works ......................................................................... 639 1. The 8bit data bus .................................................................................................................. 640 2. Memory ................................................................................................................................. 640 3. Special Function registers ..................................................................................................... 641 A simple program to demonstrate the AVR in operation ............................................................ 641

Keypad- polling versus interrupt driven ..................................................................................... 645 Improving the HT12 radio system by using interrupts ................................................................ 650 Magnetic Card Reader .............................................................................................................. 652 Card reader data structure ........................................................................................................ 652 Card reader data timing ............................................................................................................ 653 Card reader data formats .......................................................................................................... 654 Understanding interrupts in Bascom- trialling ............................................................................ 654 Planning the program ................................................................................................................ 657

69 SSD1928 based colour graphics LCD ............................................................................ 759 69.1 69.2 69.3 69.4 69.5 69.6 69.7 69.8 69.9 69.10 69.11 69.12 69.13 69.14 69.15 69.16 69.17 69.18 69.19 69.20 69.21 69.22

System block diagram ............................................................................................................... 759 TFT LCDs ................................................................................................................................. 760 System memory requirements .................................................................................................. 761 System speed ........................................................................................................................... 761 SSD and HX ICs ....................................................................................................................... 761 Colour capability ....................................................................................................................... 761 SSD1928 and HX8238 control requirements ............................................................................. 762 SSD1928 Software ................................................................................................................... 763 SSD1928 microcontroller hardware interface ............................................................................ 767 Accessing SSD control registers ........................................................................................... 768 SSD1928_Register_routines.bas .......................................................................................... 771 Accessing the HX8238. ......................................................................................................... 775 SSD1928_GPIO_routines.bas............................................................................................... 775 LCD timing signals ................................................................................................................ 777 HX setups ............................................................................................................................. 778 SSD setups ........................................................................................................................... 779 SSD line / HSync timing ........................................................................................................ 780 SSD row / VSync/ frame timing ............................................................................................. 781 HX and SSD setup routine .................................................................................................... 783 "SSD1928_HardwareSetup_Routines.bas ............................................................................. 783 SSD1928_Window_Control_Routines.bas ............................................................................ 787 Colour data in the SSD memory ............................................................................................ 790

Traffic Light help and solution ....................................................................................... 800 USB programmer - USBASP ........................................................................................... 806 USBTinyISP programmer ................................................................................................ 808 Various AVR development board schematics and layouts .......................................... 812 AVR Development Board 2 ....................................................................................................... 815 Dev board version 2 circuit diagram .......................................................................................... 816 Dev board pcb layout version 2 ................................................................................................. 817 ATMEGA V4b development board circuit – 12TCE 2011 .......................................................... 818 V4b devboard layout 12TCE 2011 ............................................................................................ 819 ATMega Dev PCB V5DSchematic (2012) ................................................................................. 820 ATMega Dev PCB V5DLayout (2012) ....................................................................................... 821 ATMega Dev PCB V5D Copper (2012) ..................................................................................... 822

128x64 GLCD Schematic – VerC -data on portB ...................................................................... 827 128x64 GLCD Layout – VerC –data on portB ........................................................................... 828 128x64 GLCD Schematic – VerD -data on portB ...................................................................... 829 128x64 GLCD Layout –VerD -data on portB ............................................................................. 830

1. Develop an understanding of what a computer is and build a correct mental model for one a. Input and output conversion at the voltage level b. Conversion of input and output voltages into data c. Processing and manipulating data which is stored in variables 2. Get to know about the hardware you are using a. Get a copy of the datasheet b. Learn about the power supply required c. Learn how to configure pins as either input or output d. Learn how to interface common I/O circuits: LED’s, Switches, Piezo, LDR… e. Find out about the different types of memory and amount of each f. Find out about the speed of processing 3. Get to know the language and the IDE you are using a. Learn to access the helpfile (e.g. highlight a word and press F1) b. The language has syntax (specific grammar/word rules) you must use correctly c. The IDE (Integrated Development Environment) has special commands and built in functions you must know and use: F7, F4, $crystal, $regfile, config, alias, const, port, pin d. Learn common I/O functions: set, reset, locate, LCD, GetADC e. Understand the limitations of and use variables: byte, word, long, single, double f. Use constants instead of numbers in the code (e.g. waitms timedelay) g. Get to know the control functions: Do-Loop (Until), For-Next, While-Wend, If-Then (Else) h. Get to know about text and math functions (read help file, write a few simple programs using the simulator) 4. Develop Algorithms (written plans for the process the program must carry out) a. Have a goal in mind for the program – use specifications and write a simple brief b. Plan your I/O by drawing a system block diagram c. Determine variables and constants required in the program d. Determine the state of all the I/O when the program begins e. Write the algorithm – Identify, order and describe the major processes the micro must do. 5. Draw Flowcharts or Statecharts (visual diagram for the process the program must carry out) a. Identify the blocks/states that will be used b. Use arrows to link the blocks and visualise control processes and program flow 6. Develop code from the flowcharts a. The outer looping line is replaced with a do-loop b. Backwards loops are replaced with do-loop do-loop-until, for-next, while-wend c. Forward loops are generally replaced with If-Then-EndIf d. Replace the blocks with actual commands e. Layout the code with correct indentations(tabs) to improve readability f. Learn to comment code so that it explains what is happening (not just describes) g. Use subroutines to organise complex code so that logic code is separate from I/O code h. Trial different ways of solving the problem and keep records of you experiments This is not a step by step process; as when you get to know about one area you get to know about others at the same time. The key to gaining depth in your knowledge and understanding comes from LOTS OF EXPERIMENTATION! That means making mistakes and above all having fun, you need to know that good decisions come from experience and experience comes from bad decisions!!! So experimenting is ok. In your electronics courses at school the aim is not to make you an expert in all the above (expertise comes after about 10 years working in an area), the aim is to introduce you to microcontroller electronics and programming, and to understand some of what is happening in the world around you and to feel able to see that you can control it and not have it control you. 98

A microcontroller is a general purpose electronic circuit; it is a full computer inside a single integrated circuit (IC or chip). Often ICs have fixed functions e.g. the TDA2822M amplifier or LM358 opamp, they only do one job and their input and output pins have fixed roles, so you have limited control over what they do, and therefore limited control over how to connect them. With a microcontroller however you are in control, you decide:  what the function of the IC is  what most of the pins are used for (inputs or outputs)  and what external input/output devices these pins are connected to. If you want an egg timer, a car alarm, an infrared remote control or whatever, it can all be done with a microcontroller. A commercial range of microcontrollers called ‘AVR’ is available from ATMEL (www.atmel.com). You could start with the ATTiny461, it has 4kbytes of Flash for program storage, 128 bytes of Ram and 128 bytes of EEPROM for long term data storage. Or you could start with the ATMega48, it has 4kbytes of Flash, 512 bytes of RAM and 256 bytes of EEPROM. ATTiny461

The AVR is a microcontroller from which manufacturer________________ The URL for their website is: ________________________ Download the specific datasheet for our microcontroller (the summary version not the full version) and print the first 2 pages and put them in your journal. The Programmable Memory size is ______ The SRAM size is _______The EEPROM size is _______ The number of I/O lines is __________ and they are arranged in _______ports

BASCOM-AVR is a compiler from _____________________ The URL for their website is: ________________________ Download the latest version of the BASCOM AVR demo and install it on your PC. There are a number of application notes on the website for the AVR Describe what AN128 is about __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________

There are a number of other great resource websites for the AVR and BASCOM Find 3 websites on the internet that have useful resource information on BASCOM List the websites URL and what you found there __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________ __________________________________________________________________________

11 Getting started with AVR Programming Microcontrollers, such as the ATMEL AVR, are controlled by software and they can do nothing until they have a program inside them. The AVR programs are written on a PC using BASCOM-AVR. This software is a type of computer program called a compiler, it comes from www.mcselec.com. It comes in a freeware version so students may download it and use it at home. The AVR is connected to the PC with a 5 wire cable.

The 5 pin header (connector) is for programming the AVR from a PC. The 0.1uF capacitor between 0V and VCC is to reduce any variations in power supply voltage. The 10k is a pull-up resistor for the reset pin, a low (connection to ground) on this pin will halt the microcontroller and when it is released(pulled high by the resistor) the program will run from the beginning again. The 1N4148 is a protection diode that will stop high voltages possibly damaging the microcontroller (it is only required on the reset pin because all the other microcontroller pins have built in protection diodes). The 0.1uF capacitor and 100R resistor are the power supply for the ADC circuit

A five wire cable is needed to connect the AVR circuit to a PC. It connects the PC’s parallel port to the AVR circuit. One end has a DB25M connector on it (as in this picture)

12 Getting started with Bascom & AVR BASCOM-AVR is four programs in one package, it is known as an IDE (integrated development environment); it includes the Program Editor, the Compiler, the Programmer and the Simulator all together.

When you have successfully compiled a program pressing F4 or the green IC picture in the toolbar starts the programmer. If no microcontroller is connected an error will pop up. If the IC s connected then the BASCOM completes the programming process and automatically resets your microcontroller to start execution of your program.

Flash1LEDv1.bas Type the code below into BASCOM, save it, then F7 to compile and then F4 to program ‘ Flash1LEDv1.bas "-----------------------------------------------" Compiler Setup (this tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom must know the micro $crystal = 1000000 "bascom must know its speed "-----------------------------------------------" Hardware Setups " (these tell bascom how to setup our micro) Config Porta = Output "LEDs on port "-----------------------------------------------" Declare Constants " (these tell bascom names we will use for numbers " in our program, this makes it easy "to change things quickly later) Const Flashdelay = 150 ‘ preset how long a wait will be "-----------------------------------------------Do ‘start of a loop Porta = &B10000000 ‘ LED 7 on Waitms Flashdelay ‘wait a preset time Porta = &B00000000 ‘all LEDs off Waitms Flashdelay ‘wait a preset time Loop ‘return to do and start again End YOU NEED TO INDENT CODE BETWEEN ALL CONTROL STRUCTURES SUCH AS WITH THIS DO-LOOP, it really helps make your code more readable and easier to debug! Use the TAB key in Bascom to do it.

This is a typical first program to test your hardware Every line of the code is important. $regfile=”attiny461.dat”, Bascom needs to know which micro is being used as each micro has different features; this is the name of a file in the Bascom program folder with every detail about the ATTiny461. $crystal=1000000, This line tells Bascom the speed at which our microcontroller is executing operations 1 million per second)so that Bascom can calculate delays such as waitms properly Config porta=output, each I/O must be configured to be either an input or output; (it cannot be both at once) Const Flashdelay=150, ‘constants’ are used in a program, it is easier to remember names and it is useful to keep them all together in one place in the program (this is a code of practice). DO - LOOP statements enclose code which is to repeat forever; when programming it is important to indent (tab) code within loops; this makes your code easier to follow (this is a code of practice). Waitms flashdelay wait a bit, a microcontroller carries out operations sequentially, so if there is no pause between turning an LED on and turning it off the led will not be seen flashing Output Code Porta = &B10000000 make porta.7 high (which will turn on the LED connected to that port) and make all the other 7 output pins on that port low Porta = 0 make all 8 pins on porta low (which will turn off any LEDs connected to that port)

In the code throughout this book different AVR microcontrollers are referred to in different places. So take special note of the $regfile and $crystal commands used and make sure they match the micro you are using. Note that the ATTiny461 and ATMega48 both run by default at 1,000,000MHz while the ATMega8535 runs at 8,000,000 MHz. You will also have to make changes to the ports used in the program: the ATTiny461 has ports A & B, the ATMega48 has B, C & D, the Amega8535 ahd ports A, B, C & D.

Note the change to $regfile and $crystal (If the timing of the flashing is wrong then try $crystal=1000000 (as AVRs often come setup at 1MHz not 8 MHz)

"this program shows how to write code which controls the whole port at "once using the commands portA=&B0000000, rather than individual set and ‘reset commands which are very wasteful of code space when multiple LEDs ‘have to "be contolled (excellence comment) "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Config Porta = Output Config Portb = Output "-----------------------------------------------------------------" Declare Constants (these tell bascom names we will use for numbers in " " our program, this makes it easy to change things quickly later) " times have been made shorter for testing purposes Const Delaytime = 25 Do Porta = &B10000000 "1 =A.7 Waitms Delaytime Porta = &B01000000 "2 =A.6 119

Bascom’s sound command can be used to directly make a tone. Piezo alias portA.3 Sound piezo, 500, 300 ‘that’s all that’s required The Bascom sound command has three parameters (values) attached ot it.  The port or pin of the microcontroller used  The duration of the sound (number of pulses)  The time the pin is high and low for. This command is not easy to use to get accurate tones from your AVR, but they do make useful sounds. Experiment with the sound command and make a series of tones suitable for an alarm. "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Output "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Leda4 Alias Porta.4 Piezo Alias Portb.3

"-----------------------------------------------------------------" Declare Constants (these tell bascom names we will use for numbers in " " our program, this makes it easy to change things quickly later) " times have been made shorter for testing purposes Const Flashdelay = 150

In this first program we would like the LED to change from off to on every time the switch is pressed. “When the switch is pressed change the LED” "-----------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Redsw = 0 Then "only do if switch pressed Toggle LED End If Loop End

We alter the program to wait a bit after the switch is pressed, which will give us time to release ithe switch “When the switch is pressed change the LED” "-----------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Redsw = 0Then " wait until switch press Toggle LED Waitms waitdelay End If Loop End

“If the switch is pressed, debounce the switch then toggle LED” "---------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "----------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb.5 = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) RedSw Alias Pinb.6 " hardware alias "---------------------------------------" Program starts here Do If Sw = 0 Then Waitms debouncetime Do Loop until Sw = 1 Waitms debouncetime Toggle Led End If Loop End

"-----------------------------------------------------------------" Title Block " Author: B.Collis " Date: 1 Aug 2008 " File Name: PedestrianCrossingLightsVer3.bas "-----------------------------------------------------------------" Program Description: " reads switch to check if pedestrian wants to cross " and changes the lights "-----------------------------------------------------------------" Compiler Setup (these tell Bascom things about our micro) $regfile = "attiny461.dat" "bascom needs to know the micro $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------------------------" Hardware Setups (these tell bascom how to setup our micro) " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases (these tell bascom names we will use for I/O devices " attached to the Micro, names are easier to remember that ports) Greenlight Alias Porta.7 Orangelight Alias Porta.6 Redlight Alias Porta.5 Crossbutton Alias Pinb.6 Crossnowlight Alias Porta.3 Dontcrosslight Alias Porta.4 "-----------------------------------------------------------------" DIMENSION VARIABLES (a variable can be changed during the program, so we might have different delays at different times of the day (maybe before and after school we could change the orange and cross delay)

"----------------------------------------------" Compiler Setup $regfile = "attiny461.dat" $crystal = 1000000 "bascom needs to know its speed "-----------------------------------------------" Hardware Setups " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb = Input "switches on portB " Hardware Aliases Green Alias Porta.1 Red Alias Porta.0 "-----------------------------------------------" Declare Constants Const Orangedelay = 7 Const Crossdelay = 20 Const Dontcrossdelay = 5 "----------------------------------------------" Program starts here "Declare Constants Const Lightontime = 500 Const Lightofftime = 2500 "---------------------------------------------"Declare Variables Dim Count As Byte "----------------------------------------------Program starts here Do For Count = 1 to 20 Set Red Waitms Lightontime Reset Red Waitms Lightofftime Incr Count Next For Count = 1 to 20 Set Green Waitms Lightontime Reset Green Waitms Lightofftime Incr Count Next Loop End

1.Type in the program COMPLETE THE MISSING PARTS, save it, Compile (F7) and Simulate it (F2). In the simulator window Step A: Choose the menu button with LCD, to open Hardware Simulation Step B: Select the switch inputs PinB.0 through PinB.4 as high (this simulates pullup resistors) Step C: Select the upper most blank yellow box in the variable area. Then double click it to get a drop down box. Then choose cars Do this for the 3 other variables

Variabes must start with a letter not a digit e.g. Dim Red_cars As Byte not Dim 1cars As Byte Variabes must not be Bascom reserved(special) words e.g. Dim band As Byte not Dim And As Byte Variables must contain no spaces e.g. Dim Red_cars As Byte not Dim Red cars As Byte Variable names should relate to what the variable is used for e.g. Dim Red_cars As Byte, not Dim hgashg As Byte Variable names cannot be used for other things such as constants or subroutines e.g. Dim Red_cars As Byte, means yu cannot have Const Red_cars = 12 as well

The simulator is an ideal tool for testing small parts of a program to see if you achieved what you wanted to. We will use it to explore the numerical range of different types of variables Here is some code to show off a few BASIC commands. Copy this program into BASCOM and compile it and see if you can understand what is happening and why. " ShowComandsV1.bas . $sim $crystal = 1000000 $regfile = "attiny26.dat" Config Porta = Output Config Portb = Output Config Pinb.6 = Input "dimension variables Dim Byte1 As Byte Dim Byte2 As Byte Dim Word1 As Word Dim Int1 As Integer Dim Single1 As Single Dim Single2 As Single

Every microcontroller has different amount of RAM available for storing variables Carry out research on these different AVR microcontrollers RAM size (bytes)

First lets review what a tone is. It is a repeated turning on and off of our piezo. The frequency of the tone is 1/period. The duration of the tone is the number of complete cycles. A piezo will not make a sound when you turn it on; it only makes a sound when you turn it on and off rapidly. So to make a tone we must turn the piezo on then wait a bit, then turn it off and we repeat this for the duration of the tone. In this program the tone period will be 1mS so the piezo must be on for 500uS (1/2 mS) and off for the same. Bascom has a waitus command (it is not particularly accurate but its good enough for this exercise). We want the tone to last long enough to hear it so we need to repeat it 150 times. 150 times 1mS will give us a tone duration of 150mS (0.15S). To count the number of cycles we will dimension a variable called cyclecount, and we will increase it inside a do-loop. It will count upto the max number of cycles and then we will have a 2 second break. Then it will repeat. Remember to reset cycle count to 0 or it will overflow. This program works similalrly to the Bascom SOUND command.

"-----------------------------------------------------------------" Title Block " Author: B.Collis " Date: 22 Feb 08 " File Name: SirenV1.bas "-----------------------------------------------------------------" Program Description: " This program makes a simple tone using a piezo " Program Features: " makes use of Bascom waitus (microseconds) command " introduces first use of a variable " the variable cyclecount increases from 0 until it reaches the preset (constant) " value maxcyclecount at which point there is a quiet time " the led is on when the the tone is occuring " Hardware Features " a pezo can be directly connected to the micro port " the led has a 1k resistor in series to limit the current "-----------------------------------------------------------------" Compiler Directives (these tell Bascom things about our hardware) $regfile = "attiny26.dat" "the micro we are using $crystal = 1000000 "rate of executing code "-----------------------------------------------------------------" Hardware Setups Config Portb = Output " Hardware Aliases Piezo Alias Portb.3 "use useful name PIEZO not PORTb.3 Blueled Alias Portb.4 "use useful name BLUELED not PORTB.4 "-----------------------------------------------------------------"Declare Constants Const Halfperioddelay = 500 " delay for 1/2 period Const Maxcyclecount = 150 "number of cycles to do "-----------------------------------------------------------------" Declare Variables Dim Cyclecount As Byte "-----------------------------------------------------------------" Program starts here Do Set Blueled "turn led on For Cyclecount = 0 to Maxcyclecount1 Waitus Halfperioddelay1 Set Piezo Waitus Halfperioddelay1 Reset Piezo Next Reset Blueled "turn led off Waitms 2000 "quiet time Loop End "end program

"-----------------------------------------------------------------" Title Block " Author: B.Collis " Date: 22 Feb 08 " File Name: SirenV2.bas "-----------------------------------------------------------------" Program Description: " This program makes a simple siren on a piezo " " Program Features: " makes use of bascom waitus (microseconds) command " Hardware Features: "-----------------------------------------------------------------" Compiler Directives (these tell Bascom things about our hardware) $crystal = 1000000 "the crystal we are using $regfile = "attiny26.dat" "the micro we are using "-----------------------------------------------------------------" Hardware Setups " setup direction of all ports Config Portb = Output " Hardware Aliases Piezo Alias Portb.3 "use useful name PIEZO not PORTb.3 Blueled Alias Portb.4 "use useful name BLUELED not PORTB.4 "-----------------------------------------------------------------"Declare Constants Const Halfperioddelay1 = 500 " first tone 1/2 period Const Halfperioddelay2 = 800 " second tone 1/2 period Const Maxcyclecount1 = 350 " longer than 255!!! Const Maxcyclecount2 = 150 "-----------------------------------------------------------------" Declare Variables Dim Cyclecount As Word "keep count of number of cycls(periods) Dim Sirens As Byte 175

it keeps the files that BASCOM generates for your program in one place this helps you find programs quickly when you want to it is less confusing it is good practice Save your program at the beginning when you start it, this helps guard against teachers that like to turn the computers off unexpectedly.

"-----------------------------------------------------------------" Compiler Directives (these tell Bascom things about our hardware) $regfile = "attiny26.dat" "the micro we are using $crystal = 1000000 "the speed of the micro "-----------------------------------------------------------------" Hardware Setups " setup direction of all ports Config Porta = Output "LEDs on portA Config Portb =Input "switches on portB " Hardware Aliases Led0 alias portb.0 " Initialise ports so hardware starts correctly Porta = &B11111111 "turns off LEDs "-----------------------------------------------------------------" Declare Variables " Initialise Variables " Declare Constants "-----------------------------------------------------------------" Program starts here Do Loop End

The use of subroutines as well as comments, aliases and constants will make your code easier to understand and maintain . Uncommentedandpoorlysetoutcodeislikereadingasentencewithoutpunctuationorspacestheme aningisstilltherebutitisalittlehardtofollowandunderstand. "-----------------------------------------------------------------" Title Block " Author: B. Collis " Date: May 2008 " File Name: MorseMeV2.bas "-----------------------------------------------------------------" Program Description: " send morse code using an LED " show off good use of subroutines and repitition "-----------------------------------------------------------------" Compiler Directives (these tell Bascom things about our hardware) $regfile = "attiny26.dat " bascom needs to know our micro $crystal = 1000000 " bascom needs to know how fast it is going "-----------------------------------------------------------------" Hardware Setups Config Porta = Output " make these micro pins outputs " Hardware Aliases Morseled Alias Porta.7 " the name morseled is easy to remember "-----------------------------------------------------------------" Declare Variables Dim Count As Byte "temporary variable to count repitions " Initialise Variables " Declare Constants Const Dotdelay = 250 " length of a dot Const Dashdelay = 750 " length of a dash Const Partofletterdelay = 250 " gap between parts of letters Const Endofletterdelay = 750 " gap between letters Const Endofworddelay = 1750 " gap between words "-----------------------------------------------------------------" Program starts here Do "start of a loop Gosub Send_c Gosub Send_l Gosub Send_s Waitms Endofworddelay "send more letters here Wait 5 Loop "return to do and start again End

Learning to develop useful planning tools to help solve problems such as drawings, block diagrams, tables & flowcharts. Learning about the Bascom commands SET, RESET and ALIAS 1. Understand the situation by drawing a planning diagram that explains the road layout

Then add things that it might have, an LCD, buttons, piezo, LEDs. Use the rectangle and circular buttons and other shapes to add to the device. Make sure that links between the micro and inputs/outputs are made in the right direction either coming in to the micro or out of it. Blocks are used to represent parts of the circuit, so an LED subsystem is created by just adding a circle and calling it red led. You do not show the current limit resistor, detail for that will be in the schematic. Sometimes it may be a good idea to have two separate block diagrams, one for I/O (input and output) devices and a second for the power supply (it just makes it easier to separate the two parts of your design). On the right hand side of the diagram are tables that list the outputs, inputs and variables that are created. These will be modified in later diagrams. The detail about port connections is useful in developing the setup program code f