M4 Feather, I Want to add additional LED functionality

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
andyzimmerman
 
Posts: 26
Joined: Sat Aug 15, 2020 11:49 am

M4 Feather, I Want to add additional LED functionality

Post by andyzimmerman »

I received some great assistance here the last go-round so I am hoping for yet another positive outcome. I use my Module tester for checking Model Railroad Modules.
I have built a Module tester" and basically this tester checks inputs and outputs and tells if they are "Okay", (Lines)"Switched", (wires) "Reversed" or if a wire is "Open/Shorted" I would like to add 2 bi-polar LEDs one for each Line (in this case named Red and Yellow), if the output is "okay" then the corresponding LED lights green, if "Switched" both Yellow and then Red if "Open/Shorted" or "Reversed" on the corresponding LED ( Red line or yellow line) I can post the Main.py or attach it. Hoping this will be a fairly simple thing.
Attachments
Module Tester V3.jpg
Module Tester V3.jpg (446.96 KiB) Viewed 75 times

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: M4 Feather, I Want to add additional LED functionality

Post by dastels »

Yes, it should be straight forward. A Bi-color LED is just 2 LEDs with either a common cathode or anode... essentially 2/3 of an RGB LED.

For RGB LED basics see https://learn.adafruit.com/adafruit-ard ... 3-rgb-leds.

You just need a digital output for each LED (or part of LED) you want to control.

Another alternative is to use NeoPixels. See https://learn.adafruit.com/adafruit-neopixel-uberguide

Dave

User avatar
andyzimmerman
 
Posts: 26
Joined: Sat Aug 15, 2020 11:49 am

Re: M4 Feather, I Want to add additional LED functionality

Post by andyzimmerman »

dastels wrote:Yes, it should be straight forward. A Bi-color LED is just 2 LEDs with either a common cathode or anode... essentially 2/3 of an RGB LED.

For RGB LED basics see https://learn.adafruit.com/adafruit-ard ... 3-rgb-leds.

You just need a digital output for each LED (or part of LED) you want to control.

Another alternative is to use NeoPixels. See https://learn.adafruit.com/adafruit-neopixel-uberguide

Dave
Okay, so the next question, What would the code look like, and what outputs should I use on the feather m4? I included my Main.py here so you can see what is already going on. I like the idea of the RGB. Green if result="Okay" Yellow if result ="Switched" Red if result is "open or shorted" and blue if the lines are "reversed" need two LEDs one for the "Red" one and one for the "Yellow" line. Thanks in advance!
main.py
(2.68 KiB) Downloaded 1 time
main.py
(2.68 KiB) Downloaded 1 time

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: M4 Feather, I Want to add additional LED functionality

Post by dastels »

If you do use an RGB LED, you'll need 3 PWM capable pins. Most of the digital pins will do. See https://learn.adafruit.com/assets/101972. If you use a NeoPixel you just need 1 digital pin. PWM in CircuitPython is covered here: https://learn.adafruit.com/circuitpytho ... python-pwm. If you just need red, yellow, green, and blue you don't even need PWM: just 3 digital pins (one for each of red, green, and blue... yellow = red+green). See https://learn.adafruit.com/circuitpytho ... tal-in-out.

Dave

User avatar
andyzimmerman
 
Posts: 26
Joined: Sat Aug 15, 2020 11:49 am

Re: M4 Feather, I Want to add additional LED functionality

Post by andyzimmerman »

Thank you for your support, Sorry my Circuit Py skills are marginal at best. So your assistance is much appreciated. Looking for an additional function. I accidentally purchased the Adafruit FeatherWing OLED - 128x64 OLED Add-on For Feather (https://www.adafruit.com/product/4650) vice the usual 128x32 OLED. I know it needs a different driver (adafruit_displayio_sh1107) and I know that it has to be added in these first 10 lines. It is probably simple, but I have tried a few things but when I did get am output it wasn't what I expected. (too much experimentation) So if I want to be able to use this display what do I need to add and/or change? Removing any reverence to the SSD1306 i am sure, but what goes in its place? I substituted Import adafruit_displayio_sh1107 for line 6 mport adafruit_ssd1306 but then line 10 has a fit "OLED=" obviously I need something different there but what am I missing?
Fist 10 lines=
# import appropriate device libraries
import board
import busio
import time
from digitalio import DigitalInOut, Direction, Pull
import adafruit_ssd1306
# define setup for display board
i2c = busio.I2C(board.SCL, board.SDA)

oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”