This is an old revision of the document!


Exercises

The goal is to make a program witch is able to perform specified task.

Warm up exercise

  • If pressing S1 it one LED is lighted, pressing S2 two LED-s and S3 three LED-s.

For beginners

  1. It simulates traffic light when the button is pressed. Until no button is pressed the yellow light is blinking (traffic light in night mode). After pressing a random button the traffic light starts working in everyday mode, lighting yellow, then red and before continuing again yellow
  2. Counts how many times the button is pressed. The pressing is considered as ended after the button is released. The result is displayed is binary code on LED-s. Maximum result when using three LED-s is 7(23-1). Green is 1. bit, yellow 2. bit and red 3. bit.
  3. By pressing switch S1, LED1 and LED3 are lighted, pressing S2 yellow LED is lighted, pressing S3 all LED-s are switched off. This operation must be done by changing directly values of corresponding registers (without using the library of the home lab).
  4. Counts how many times the button is pressed. The result is displayed by blinking LED-s. After every press the number of blinking is raised by one. Random button may be selected. Blinking the LED sub function witch’s parameter is the number of blinks must be used.
  5. 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”.

For advanced

  1. For each button of three corresponds one LED witch lights when the button is pressed. To turn on or turn off registers must be used and only one assigning operation (hint: use bit shifts).
  2. When pressing the buttons in following sequence: S3-S2-S1, green LED is lighted. If other combinations are used only yellow will blink confirming that the button is pressed.
  3. There is one button for each LED. The controller blinks LED-s randomly and the user has to repeat that sequence. The sequence of blinks is longer each time – one random LED is added. After the user has had his turn his turn is controlled whether it was correct. The time gap between each entry is two seconds. In case of incorrect entry all LED-s are blinked three times. (The number of correct entries by the user may be displayed on a LCD).
  4. The program measures time for reaction. When a random LED is lighted, the user has to press the corresponding button. The time when the LED is lighted is random, but at least 100 ms. The result is displayed on a LCD in milliseconds. The value of the buttons can not be read with the function that filters flickering because it results an extra delay.

Questions

  1. Mis on tehete “=” ja “==” erinevus? Esitage selle erinevuse tõestuseks kaks näidet.
  2. Mis on tehete “|” ja “||” erinevus? Esitage selle erinevuse tõestuseks kaks näidet.
  3. Kirjutage avaldis, milles kasutate võrrandit “x = x + 1” kaksteist korda.
  4. Kuidas kirjutate C-keeles lõputu tsükli?
  5. Millist tüüpi muutuja valite C-keeles, et esitada positiivseid arve vahemikus 7 kuni 154?
  6. Milline register määrab ära pordi suuna? Tooge pordi näide sisendi ja väljundi seadistamise kohta.
  7. Milliste meetoditega saab elimineerida nupu värelust? Tooge näiteid riistvaralise ja tarkvaralise lahenduse kohta.
  8. Mida tähendab termin bitinihutus? Tooge praktiline näide koos seletusega.
  9. Miks kasutatakse lülitite juures pull-up-takistit? Mille järgi määratakse selle takistus?
  10. Arvutage LED voolu piirava takisti väärtus, kui toitepinge on 5 V, LED päripinge 2,7 V ja vool 30 mA.
en/exercises/digi.1265536219.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