This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:exercises:digi [2009/09/25 14:32] – rellermaa | en:exercises:digi [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | Digital board' | + | The goal is to write a program which is able to perform tasks described below. |
- | The program can be used to test if the board is in working order. | + | |
- | ===== Digital i/o ===== | + | ===== Warm up exercise |
- | Write the program that ... | + | *By pressing S1 one LED is lit, pressing |
- | - ... when pressing | + | |
- | - ... simulates the traffic light sequence on LEDs (green blinking, etc.) ({{: | + | |
- | - ... counts the button pressed | + | |
- | - ... simulates door code lock. When pressing switches in this order S3 – S2 - S1 green LED goes on. All other combination will end up red LED. Every button pressing is indicated with yellow LED.({{: | + | |
- | - ... simulates memory game. Every LED corresponds a button (LED1=> | + | |
- | - ... measures reaction time. Program start when one button is pressed, then a LED goes on and user have to press a button under the LED. Sequence and time when LED goes on is random. Best result in milliseconds is presented to the user (on the 7-seg display or LCD).({{: | + | |
+ | ===== For beginners ===== | ||
- | ===== Timers ===== | + | - This simulates manually operated traffic light at pedestrian crossing. Until no button is pressed a green LED is lit for the cars. After pressing a random button the green LED will start to blink for 3 seconds, this is followed by lighting the yellow LED for 3 seconds and red for 10 seconds, after this sequence a green LED is lit again. |
- | Write the program that ... | + | - This counts how many times the button is pressed. Only the full release of the button will complete the pressing. The result is displayed in binary code on LEDs. Maximum result for three LEDs is 7(23-1). Green marks 1. bit, yellow 2. bit and red 3. bit. |
- | - ... flashes | + | - By pressing switch |
- | - ... flashes LEDs with different frequency using timer. S1 increases flashing frequency | + | - This counts how many times the button is pressed. The result is displayed by blinking of the LEDs. After each pressing the number of blinking is increased by one. A random button can be selected. In order for the LED to blink a sub function must be used, with parameters set on the number of blinks. |
+ | - When pushing button | ||
- | ===== 7-seg number indicator | + | ===== For advanced |
- | Write the program that ... | + | |
- | - ... counts numbers | + | - For each of the three buttons corresponds one LED which lights up when the button is pressed. For turning on or off, registers must be used and only one assigning operation (hint: use bit shifts). |
+ | - For each of the three buttons corresponds one LED which lights up when the button is pressed. For turning on or off, registers must be used and only one assigning operation (hint: use bit shifts). | ||
+ | - There is one button for each LED. The controller blinks LEDs randomly and the user has to repeat the same sequence. The sequence of blinks gets longer – one random LED is added with a new round. The sequence is controlled after each user. The time gap between each entry is two seconds. In case of an incorrect entry all LEDs blink three times. (The number of correct entries by the user may be displayed | ||
+ | | ||
+ | |||
+ | ===== Questions ===== | ||
+ | |||
+ | - What is the difference between operations”=” and”==” ? Give two examples | ||
+ | - What is the difference between operations “|” and “||”? Give two examples to verify the statement. | ||
+ | - Write an expression using the equation “x = x + 1” twelve times. | ||
+ | - How an endless loop is written in C-programming language? Provide two different | ||
+ | | ||
+ | - Witch register determines the direction of a port? Provide an example of configuring settings of ports’ input and output. | ||
+ | - What are the methods for eliminating the bouncing of the contacts and the false connections caused by flickering? Provide examples of solutions using both hardware and software. | ||
+ | - What is bit shift? Give a practical example with an explanation. | ||
+ | - Why are pull-up resistors used in switches? How is their resistance determined? | ||
+ | - Calculate the resistance for regulating LED current, the voltage is 5 V, forward voltage of the LED is 2,7 V and the current is 30 mA. |