This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:examples:digi:led [2015/11/04 14:06] – heikopikner | en:examples:digi:led [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~PB~~ | + | < |
====== Light-emitting Diode ====== | ====== Light-emitting Diode ====== | ||
- | //Necessary knowledge: [HW] [[en: | + | //Necessary knowledge: |
+ | [HW][[en: | ||
+ | [ELC][[en:electronics:led_resistor]], | ||
+ | [AVR][[en:avr:registers]], [AVR] [[en:avr:io]], | ||
+ | [LIB][[en:software:homelab: | ||
===== Theory ===== | ===== Theory ===== | ||
Line 22: | Line 26: | ||
===== HomeLab Practice ===== | ===== HomeLab Practice ===== | ||
- | The HomeLab controller control module has one single | + | The HomeLab controller control module has one single |
All practical examples for the HomeLab kit, LED switching included, use HomeLab’s pin library. Pin library includes data type //pin//, which contains addresses of pin related registers and pin bitmask. If to create a pin type variable in the program and then initialize it by using macro function PIN, the pin can be used freely with this variable (pin) through whole program without being able to use registers. | All practical examples for the HomeLab kit, LED switching included, use HomeLab’s pin library. Pin library includes data type //pin//, which contains addresses of pin related registers and pin bitmask. If to create a pin type variable in the program and then initialize it by using macro function PIN, the pin can be used freely with this variable (pin) through whole program without being able to use registers. | ||
- | Here are 2 example programs, which are doing exactly the same thing, but one is created on the basis of HomeLab’s library, the other is not. | + | Here are 2 example programs, which are doing exactly the same thing, but one is created on the basis of HomeLab’s library, the other is not. The debug LED, led_debug in HomeLab library, has been described as PB7 (HomeLab I & II) and PQ2 (HomeLab III). The Debug LED is physically located in the Controller module. |
<code c> | <code c> | ||
- | // | + | // HomeLab Controller module LED test program, which |
- | // HomeLab Controller module LED test program. | + | // is based on HomeLab library |
- | // The code is base on HomeLab library. | + | |
- | // | + | |
#include < | #include < | ||
- | // | ||
// LED pin configuration. | // LED pin configuration. | ||
- | // | + | pin led_debug |
- | pin debug_led | + | |
- | // | ||
// Main program | // Main program | ||
- | // | ||
int main(void) | int main(void) | ||
{ | { | ||
// Configuring LED pin as an output | // Configuring LED pin as an output | ||
- | pin_setup_output(debug_led); | + | pin_setup_output(led_debug); |
// Lighting up LED | // Lighting up LED | ||
- | pin_clear(debug_led); | + | pin_clear(led_debug); |
} | } | ||
</ | </ | ||
<code c> | <code c> | ||
- | // | + | // HomeLab |
- | // HomeLab Controller module LED test program. | + | // accesses |
- | // The code directly | + | |
- | // | + | |
#include < | #include < | ||
- | // | ||
// Main program | // Main program | ||
- | // | ||
int main(void) | int main(void) | ||
{ | { |