Put your code in code brackets, so that indentation is kept. Fixed for you.derekiwi wrote:Hi Flatmax,
I am also a total newbie to Pi, Linux etc. I started with RPi.GPIO, and it is easy to use and learn. I was going to attach a sample for you but the forum does not let me, so pasted in below.. Currently having a look at wiringPi - seems just as easy and documentation is better. But I would start with RPi.GPIO.
RPi.GPIO should be installed on your Raspberry already if you are using Rasbian and have the latest version. Otherwise ....
https://sourceforge.net/p/raspberry-gpi ... i/install/ (note that you do not need Mercurial)
http://wiringpi.com/
Cheers, DerekCode: Select all
#!/usr/bin/env python # import time import sys import RPi.GPIO as GPIO # # gpio may still open from last session if abnormally exited GPIO.setwarnings(False) # # set to defining by header pins, instead of BCM GPIO.setmode(GPIO.BOARD) # print ("System Setup.") print (GPIO.RPI_INFO) # # set up gpio ehader pin 35 (BCM and GPIO 19) as output TestPin = 35 GPIO.setup (TestPin, GPIO.OUT) # print ("Main loop start....") # ############################# # Main loop ############################# # try: while True: # toggle the pin each loop GPIO.output(TestPin, True) time.sleep(0.25) GPIO.output(TestPin, False) time.sleep(0.25) # # press Ctl-c to exit except KeyboardInterrupt: GPIO.cleanup() print ("Cleaned up. Bye.") sys.exit(0) #
GPIO Zero was designed to be the easiest way of programming GPIO devices. It's pre-installed with Raspbian and easy to get started. Just open IDLE (preferably Python 3) and type commands like the above!recantha2 wrote:Python, using the GPIO Zero library would seem to be appropriate.
from gpiozero import LED
red = LED(4)
red.on()