tajiknomi
Posts: 11
Joined: Thu Jan 01, 2015 2:52 pm

GPIO.cleanup() Issue

Sat Jan 17, 2015 10:53 am

I had Write a Simple Script for my PI with GUI build in TKinter...

Issue with "GPIO.cleanup()" is = Its Clean-Up the Ports that are Used in Program but "ReEnter" to that Status Once the Programmed is Run again,

So here in My Program, If i click the buttons once, Means all LED are On, Then i press the "Exit" Button to Exit it, In an "Exit fucntion" i had add the GPIO.cleanup() function, I clear all the ports, means all led are off once the Program is Ended, But it remain HIGH when i run the program again,

Mean GPIO.cleanup() only Pause my GPIO status, But when i run the program again, Its Runs from the same status it left previously,
I had attached my code here with > https://dl.dropboxusercontent.com/u/16158781/all.py

User avatar
davidcoton
Posts: 4881
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO.cleanup() Issue

Sat Jan 17, 2015 11:06 am

Why is that a problem? Often it takes masses of code to preserve program state between runs. (I suspect it will not be preserved if the Pi is turned off.)

If you want, you can turn the LEDs off in your exit function.
Signature retired

User avatar
croston
Posts: 706
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: GPIO.cleanup() Issue

Sat Jan 17, 2015 11:14 am

On your GPIO.setup() calls, the pull down parameter is only valid for a channel being set up as an input.

I think what you want is replace the pull_up_down parameter with initial=GPIO.LOW

This is explained in the manual as can be found here:
https://sourceforge.net/p/raspberry-gpi ... asicUsage/
or by doing a help(GPIO.setup) at the Python console.

tajiknomi
Posts: 11
Joined: Thu Jan 01, 2015 2:52 pm

Re: GPIO.cleanup() Issue

Sat Jan 17, 2015 11:26 am

Thanks, " initial=GPIO.LOW " Solve the Problem,

Return to “General discussion”