• Embedded systems usually use switches as part of their user interface. • This general rule applies from the most basic remote-control system for opening a garage door, right up to the most sophisticated aircraft autopilot system. • Whatever the system you create, you need to be able to create a reliable switch interface. On Off 1 4 7 2 5 8 3 6 9 1 2 Start Engage AP Temporary Manual 3 4 5 Disengage AP Up and Around STOP 0 Enter In this seminar, we consider how you can read inputs from mechanical switches in your embedded application. Before considering switches themselves, we will consider the process of reading the state of port pins. COPYRIGHT ©. | Seminar 3 Reading Switches 4 To pin on Port 1 Port 2 or Port 3. Copyright Michael J. Pont 2001-2006. Contains material from Pont . 2002 Embedded C Addison-Wesley. PES I - 45 Introduction Embedded systems usually use switches as part of their user interface. This general rule applies from the most basic remote-control system for opening a garage door right up to the most sophisticated aircraft autopilot system. Whatever the system you create you need to be able to create a reliable switch interface. I II I In this seminar we consider how you can read inputs from mechanical switches in your embedded application. Before considering switches themselves we will consider the process of reading the state of port pins. Copyright Michael J. Pont 2001-2006. Contains material from Pont . 2002 Embedded C Addison-Wesley. PES I - 46 Review Basic techniques for reading from port pins We can send some data to Port 1 as follows sfr P1 0x90 Usually in header file P1 0x0F Write 00001111 to Port 1 In exactly the same way we can read from Port 1 as follows unsigned char Port_data P1 0xFF Set the port to read mode Port_data P1 Read from the port Copyright Michael J. Pont 2001-2006. Contains material from Pont . 2002 Embedded C Addison-Wesley. PES I - .