Solenoid Engine Single – Raspberry Pi – Simple – Python


#
# Solenoid Engine Simple Script - Flat out Speed
# sudo apt-get install python-rpi.gpio
# python soleng.py
#
# Import the required module.
import RPi.GPIO as GPIO

#define pins
# WiringPi 7 = gpio 4 = pin 7
NOTEYE = 7
# wiringPi 0 = gpio 17 = pin 11
SOL = 11

# Set the mode of numbering the pins.
GPIO.setmode(GPIO.BOARD)
# GPIO pin 10 is the output.
GPIO.setup(SOL, GPIO.OUT)
# GPIO pin 8 is the input.
GPIO.setup(NOTEYE, GPIO.IN)

while 1:
 # if GPIO.input(NOTEYE) == 0: For V1 Engines
 if GPIO.input(NOTEYE) == 1:
  GPIO.output(SOL,1)
 else:
  GPIO.output(SOL,0)