Embedded systems are ubiquitous, a wide variety of industrial and consumer products are equipped with embedded processors that interact with the electrical and mechanical parts of the product. The software engineering practices for embedded systems, however, are still rather primitive. The languages employed are very low level and there is a need for better testing tools. Teaching embedded systems programming is challenging, since it involves many aspects of computer science and electrical engineering technologies. The traditional teaching approaches involve either an expensive laboratory for small numbers of students or are limited to theory without teaching programming skills.We are developing a hardware-in-the-loop simulation environment for embedded sytems for use both as a teaching tool and as a software development and testing tool. This simulation environment allows programming an actual embedded processor, while some or all of the electrical and mechanical devices controlled by the embedded processor, such as power switches or motors, are simulated on the PC. This approach can be used for teaching larger numbers of students without the need for an expensive hardware laboratory. This hardware-in-the-loop simulation environment can also serve as a testing tool for testing individual embedded systems with part of the hardware attached but with other hardware or the communication with other processors being simulated. We are currently working on developing a testing tool based on timed automata for this environment for testing the order of events and timing constraints on the interface between the embedded processor and the external devices. A translator, the Timed Automaton COmpiler (taco), generates a timed automaton implementation from a high-level specification similar to object protocols. Once this virtual testbed is completed, we are planning to use it as a research platform for developing language support and better software engineering tool support for embedded systems programming.