Hello!
I have a Grove PI zero, I would like to connect more than one led light to the Pi. Im connecting the first one to D3, and it works perfectly. I’d like to connect another led to an analog port and access it using the analogWrite() function, however, its not working.
Any help would be greatly appreciated!
Hi @amitvasudevan.nabi2,
Please, go on the following Github page and scroll down to the GrovePi Zero
section.
With the hardware diagram in front of you, please tell us what to what ports you’re trying to connect the LED
s and then show us your Python script
.
The last thing: is your GrovePi Zero
updated to the latest firmware? You also need to run the latest version of Raspian For Robots
in order to be sure of its functionality.
Thank you!
I tried connecting my LED to port #A1. My GrovePi Zero is updated to the latest firmware and im running the latest version of Rasbian For Robots.The program I used in Python is down below, it is a variant of the testing program
import time
from grovepi import *
led = 0
pinMode(led,"OUTPUT")
time.sleep(1)
print ("This example will blink a Grove LED connected to the GrovePi+ on the port labeled D4.\nIf you're having trouble seeing the LED blink, be sure to check the LED connection and the port number.\nYou may also try reversing the direction of the LED on the sensor.")
print (" ")
while True:
try:
#Blink the LED
analogWrite(led,1) # Send HIGH to switch on LED
print ("Jingle Bells")
time.sleep(2)
analogWrite(led,0) # Send LOW to switch off LED
print ("Jingle Bells!")
time.sleep(0.5)
#digitalWrite(led,1) # Send HIGH to switch on LED
#print ("Jingle All The Way")
#time.sleep(2)
#digitalWrite(led,0) # Send LOW to switch off LED
#print ("Oh What Fun It Is To Ride In A One Horse Open Sleigh!")
#time.sleep(5)
#digitalWrite(led,0) # Send LOW to switch off LED
#print ("HEY!")
#time.sleep(0.5)
except KeyboardInterrupt: # Turn LED off before stopping
digitalWrite(led,0)
break
except IOError: # Print "Error" if communication error encountered
print ("Error")
Hi @amitvasudevan.nabi2,
So, from now on, I’ll assume you’re having:
Now, looking at your code, I can see a discrepancy between what you told me and what’s written in there.
In the code, the LED
is connected to port A0
, but you told me you’re using port A1
for your LED
. Can you check this information and then come back?
Ideally, you could share with us a photo of your assembly. By doing it so, we can faster analyze the situation.
Thank you!
I tried the code on both A1 and A0, right now the light is connected to A0, ill try to get a photo soon.