I have an easy circuit wired up, with an LED connected to pin 18 on the BOARD reference. I run a simple program to put pin 18 to HIGH, which turns the LED on, and then a couple of seconds later, I set pin 18 to LOW, and finally I end my program with GPIO.cleanup().
At this point the LED is off, which means that pin 18 is off (LOW). Now I reboot or restart my Raspberry Pi, and when it boots back up, the LED on pin 18 turns on again, even though the pin was off before I rebooted the Raspberry Pi.
Why may this be happening? How can I configure a specific pin, like pin 18 to be off when the Raspberry Pi boots up? And I don't want any GPIO pins to be on HIGH when the Raspberry Pi boots up.
I am concerned about this problem, because let's say that pin 18 is connected to a DC motor on a robot, and when the Raspberry Pi boots up, the motor will turn on, and this is not something that I want because that will interferes with the whole structure of the robot, and some motors might start and others won't, depending on the pins they are connected to. I want to manually turn on all the motors in a synchronized manner.
One other thing is that not all the pins have this problem. Some stay off when the Raspberry Pi boots, but others don't.
/sys/class/gpio
and export pin 18, what state does the system then say it is in if you change nothing? – goldilocks Jun 18 '15 at 14:05echo
, which writes, i.e., sets something. After you export it you want to refrain from that and just usecat
, which reads, to check the direction and the value. – goldilocks Jun 18 '15 at 15:50/sys
interface to check the settings, not to play with them. If they confirm it's set high before you change anything, then the physical state is consistent with the OS, and (if you want) you can investige the device tree angle. Note doing the export may change the state -- obviously you will notice with the LED -- I'm not sure of the rules there. – goldilocks Jun 18 '15 at 16:10/sys
doesn't persist across boot. Those aren't real files. They're in memory conduits to the kernel (when you read one, you're asking for information, when you write to one, you're sending the kernel a setting), which is why they all have a size of 0, etc. – goldilocks Jun 18 '15 at 16:15/sys
says at boot. – goldilocks Jun 18 '15 at 16:28