May 2018
Intermediate to advanced
340 pages
7h 20m
English
I am sure you remember this line of code from the previous chapter:
GPIO.setup(18,GPIO.OUT)
As explained earlier, this basically tells us how GPIO the pin will behave in a certain program. By now, you must have guessed that by changing this single line of code we can change the behavior of the pin and convert it from output to input. This is how you would do it:
GPIO.setup(18,GPIO.IN)
Once you write this line of code in your program, the microcontroller will know that during the time that the program is being run, the pin number 18 will only be used for input purposes.
To understand how this would actually work, let's head back to our hardware and see how it can be done. Firstly, you need to connect an LED to any ...