It is easy to use a microcontroller to turn LEDs on and off in almost any pattern you want. (Click here for more information.) But you can only turn the LED on and off. So what if you want to control the brightness of the LED? The same problem comes up in robotics where you want to control the speed of a motor with a microcontroller. It is not good enough to just turn the motor on and off. To control the brightness of the LED or speed of the motor you have to control the amount of current going through the device. But how? One solution that may occur to you is to quickly turn the LED or motor on and off. The current only flows when the output is low (for microcontrollers LED circuits are usually wired so current flows into the microcontroller when the output is low, as shown in the tutorial at http://www.iguanalabs.com/1st2051.htm). The output of your microcontroller will look like the following square wave. (more…)
Posts Tagged ‘programming’
Controlling the Brightness of an LED (Using PWM)
Monday, June 22nd, 2009Disable/enable an individual radio button of a RadioGroup
Tuesday, December 30th, 2008source : http://www.festra.com
The following code shows how to disable or enable an individual radio button in a TRadioGroup component, the second radio button in our example. Note that the RadioGroup.Controls is a zero based array. (more…)
Line number of the cursor in a TMemo
Monday, December 29th, 2008source : http://www.festra.com
To determine which line number the cursor of a Memo component is in, you can use the Windows API function SendMessage. (*API = Application Programmr Interface)
In the example below, the integer variable LineNumber receives the line number that the cursor of Memo1 is in:
LineNumber :=
SendMessage(Memo1.Handle, EM_LINEFROMCHAR, Memo1.Selstart, 0);
Delphi String Handling (Removing spaces)
Saturday, December 27th, 2008source : http://www.festra.com
Count each non-spaces substring as a word, if it is followed by a space, or if it comes at the end of the string. With this rule, you don’t have to worry about multiple, leading nor trailing spaces
Delphi 7 code example: (more…)
Conventional Microcontrollers
Friday, December 26th, 2008Instructions Set of the MCS-51
Wednesday, December 24th, 2008All instructions of the mcs-51 microcontroller are shown on 79 pages.
For example the instruction JB bit,rel:
(more…)
Speed up the display of Delphi list components
Monday, December 22nd, 2008source : http://www.festra.com
If you use a Delphi component like a ListBox, Memo, TreeList, ListView,… and you add or modify a lot of items (lines, nodes,…), the component’s performance becomes very slow. This is due to the fact that after each change, it is redrawn on the screen. (more…)
Flash Microcontrollers
Tuesday, October 28th, 2008Create and free Delphi form dynamically
Tuesday, October 28th, 2008source : http://www.festra.com
When creating a Delphi component dynamically (a form or whatever other component), in the Create method you have to specify its owner, for example: (more…)
Simply Ajax and Mobile
Wednesday, October 15th, 2008ZK is Ajax framework enriching Web apps with little programming. With event-driven and markup languages, development is as simple as programming desktops and authoring HTML/XUL pages. ZK supports scripting lang including Java, JavaScript, Ruby, Groovy… (more…)