Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:exercises:digi [2009/09/25 14:32] rellermaaen:exercises:digi [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== L1 Digital i/o ======+====== Exercises ======
  
-Digital board's demo/test program: {{:examples:hex:basic_v3.1_test.hex|}}. +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 litpressing S2 two LEDs and S3 three LEDs lit.
-  - ... when pressing switch 1 (S1), LED 2 lights on; continuedoing the same with S2 => LED 3 and S3 => LED 1. ({{:examples:hex:1.1_nupp_led.hex|SOLUTION}}) +
-  - ... simulates the traffic light sequence on LEDs (green blinking, etc.) ({{:examples:hex:1.2_valgusfoor.hex|SOLUTION}}) +
-  - ... counts the button pressed and showing it on LED as binary code. Max 7(23-1). (Pressing is counted only then when it is released) ({{:examples:hex:1.3_binaar_led.hex|SOLUTION}}) +
-  - ... 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.({{:examples:hex:1.4_code_lock.hex|SOLUTION}}) . +
-  - ... simulates memory game. Every LED corresponds a button (LED1=>S1, etc.) Controller flashed LEDs in random order and user have to repeat this order. Every next step in the sequence goes longer. After every insertion controller test the result. If wrong insertion is detected the game is over and result is presented to the user (on the 7-seg display or LCD).({{:examples:hex:1.5_memory_game.hex|SOLUTION)}}.  +
-  - ... 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).({{:examples:hex:1.6_reaction_time.hex|SOLUTION}})+
  
 +===== For beginners =====
  
-===== Timers ===== +  - This simulates manually operated traffic light at pedestrian crossing. Until no button is pressed a green LED is lit for the carsAfter 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 pressedOnly the full release of the button will complete the pressingThe result is displayed in binary code on LEDsMaximum result for three LEDs is 7(23-1)Green marks 1bit, yellow 2. bit and red 3. bit. 
-  - ... flashes LEDs with different frequency using timerFrequency can be changed by the buttons(S1 – 1 Hz, S2 – 0,5 Hz,  S3 – 0,1 Hz).({{:examples:hex:2.1_timer.hex|SOLUTION}}). +  - By pressing switch S1, LED1 and LED3 are lit; pressing S2 yellow LED is litpressing S3 all LEDs are switched offThis operation must be done by directly changing the values of corresponding registers (without using the library of the HomeLab). 
-  - ... flashes LEDs with different frequency using timer. S1 increases flashing frequency and S3 decreases.({{:examples:hex:2.2_timer.hex|SOLUTION}}).+  - This counts how many times the button is pressedThe result is displayed by blinking of the LEDsAfter each pressing the number of blinking is increased by oneA 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 S1, red LED will blink “SOS” in Morse. By pressing S2, yellow LED blinks “CQD” and by pressing S3, green will blink “OK”
  
-===== 7-seg number indicator ===== +===== For advanced ===== 
-Write the program that ... + 
-  - ... counts numbers on 7-seg display from 1 to 9If button S1 is pressed the counting starts to go backwardIf S3 is pressed the counting resumes to go forwardDigit change frequency is 1 second.({{:examples:hex:3.1_7-seg.hex|SOLUTION}}).+  - For each of the three buttons corresponds one LED which lights up when the button is pressedFor 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 LEDThe controller blinks LEDs randomly and the user has to repeat the same sequenceThe sequence of blinks gets longer – one random LED is added with a new roundThe 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 on a LCD screen).  
 +  The program measures time for reactionA random LED is lit and the user has to press the corresponding button as fast as possibleThe time when the LED is lit is random, but not less than 100 ms. the result is displayed on a LCD screen in milliseconds. The value of the buttons cannot be read with filtering function for the flickering, since this will cause an extra delay. 
 + 
 +===== Questions ===== 
 + 
 +  - What is the difference between operations”=” and”==” ? Give two examples to verify the statement. 
 +  - 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 examples. 
 +  What type of a variable do you choose in C–language to present positive values between 7 and 154? 
 +  - 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.
en/exercises/digi.1253889129.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0