Difference: LedDisplay (2 vs. 3)

Revision 32017-10-19 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Exercises 5: First Exercise on Hardware: LEDs

Goal:

Line: 28 to 28
 In order to translate your blinking program into C you will have to include <wiringPi.h>. Then you can call wiringPiSetup () to initialize the library. Finally use pinMode and digitalWrite to tel the library you want to use the pin as output pin and write to it. Check the wiringpi API documentation for the parameters of these calls. When building the program you have to link the wiringPi library to your program (-lwiringPi). The wiringpi include files and the library are stored in /usr/local/include and /usr/local/lib respectively.

Write a Makefile to build your project. Test it to make sure it works as expected.

Changed:
<
<

Exercise 5: Make your LED blink SOS

>
>

Exercise 5: Implementing your own gpio command

 
Changed:
<
<
Write a C program that makes the LED blink an SOS. Write a subroutine pulse (int pulseLength) that switches the LED on for pulsLength ms and then off again for pulseLength ms. Use this routine to implement the SOS. Wait for 1 s between each SOS sequence.
>
>
Knowing how to switch on and off the LED and knowing that you can read and write a gpio pin, can you write your own mygpio command? This command will take 2 or 3 command line parameters:
  • the strings "read" of "write"
  • the gpio pin number (0..7)
  • the logic level to be written (0 or 1) only in case of writing
Implement this command and make sure it is water tight (the user can type any rubbish and the program will react correspondingly but does not crash). Check if you can write a LED. Put the logic level at the LED onto a second GPIO pin and make sure you can read it back.

Exercise 6: Make your LED blink SOS

Write a C program that makes the LED blink an SOS. Write a subroutine pulse (int pulseLength) that switches the LED on for pulseLength ms and then off again for pulseLength ms. Use this routine to implement the SOS. Wait for 1 s between each SOS sequence.

  -- Uli Raich - 2017-01-03
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback