Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I seem to get NameError: 'gpio' is not defined

But have copied script from another programme, which doesn't give this error. What am I doing wrong?

Thanks for your advice in advance.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import time
import RPi.GPIO as GPIO

#setup pin 10 as an output

gpio.setmode(gpio.BCM)
gpio.setmode(10, gpio.OUT)

#Make an LED flash on and off forever
while True:
    gpio.output(10, gpio.HIGH)
    time.sleep(1)
    gpio.output(10, gpio.LOW)
    time.sleep(1)
like image 879
Nigel Richards Avatar asked Dec 13 '25 13:12

Nigel Richards


1 Answers

Python variable names are case-sensitive.

Replace:

import RPi.GPIO as GPIO

with:

import RPi.GPIO as gpio
like image 87
alecxe Avatar answered Dec 16 '25 01:12

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!