In This Chapter
Seeing how to access the GPIO pins under RISC OS
Making an LED blink
Mixing BASIC and machine code
In this chapter, we show you how to use the GPIO pins under RISC OS. We present the obligatory flashing LED, a sort of “Hello world!” for hardware. We also tell you how to speed up output using machine code embedded into the BASIC program. Finally, we show you how to read a GPIO input.
When you know the fundamentals of using the GPIO from RISC OS, you can handle any interfacing project. After reading this chapter, you may want to try to write the programs for the projects in Chapters 5 and 6 in BBC BASIC instead of the Python we used. Have fun using this hidden side of the Raspberry Pi!
In the last chapter, we look at using the I2C bus, which occupies just two of the pins of the GPIO connector. Both the Raspberry Pi Model A and the Raspberry Pi Model B have 17 pins available to control or monitor things, whereas the Raspberry Pi Model B+ and Raspberry Pi 2 Model B+ have 28 pins. However, in order to talk to these pins under RISC OS, you have to resort to a little trickery. ...