Peeling Elephant Garlic: Input CdS photoresistor_Output LED

Hello,
Thank you in advance for taking a moment to read this and offer assistance. I will begin the description of my project with a 2 photos.

The Bulb and husk become one unit. The seams and marriage will be tighter. The husk is removable.

The concept is that as one removes the husk a sensor recognizes this state, and there is a response.

Input:
From some preliminary research I think a Photoresistor would be the appropriate sensor. The CdS photoresistor would be mounted on/embeded on the interior bulb. When the husk is removed the CdS is exposed to more light.

Output: An LED illuminates in correlation with the state of a particular CdS Photoresitor. I.E. you remove a husk and and a LED lights up.

Note I would like there to be many Elephant Garlic bulbs in this system. I believe I will need a breakout board to accomplish this.

Question: I was able to find a tutorial for an input of many CdS Photoresitors to an Arduino Uno. I could not find a technique for correlating these inputs with an output of LED as described. To rephrase the problem statement; how can I make an LED light up in response to a photoresistor state. Additionaly how could this be accomplished on a scale of perhaps 64 of these units.

Here is a Pseudo wiring diagram:


Notice that the output(right side) is simply a copy of the input side. This is where my understanding is falling short.

Details:

The realization of this circuit will entail both an understanding the wiring and the coding. I would appreciate any insights. I was planning on using the following components, however I am open to adjustment;

  • Arduino Uno or Nano

  • CdS Photoconductive Photocells from Adafruit
    PDV-P8001.pdf (93.7 KB)
    (data sheet)
    regarding this I think the most relevant bit of information from the adafruit tutorial would be the following chart. This chart would help me code the arduino to communicate with the LED. I would be attempting to make a sort of binary signal from the photocell; i.e. either husk peeled or not.

  • Warm white LED sequins. I think this are really attractive and I just like them. Probably not the cheapest option. Here is the datasheet, and a png of the more relevant part of the data sheet.

LED_sequin.pdf (220.9 KB)

  • Sparkfun multiplexor_8channel
    image

MUX74HC_HCT4051.pdf (289.1 KB)

  • Power supply; I dont know what voltage I would need to illuminate 64 LED sequins. I understand this would depend on how bright. I would like them to be regular bright. I know this is not techinical specification. Maybe someone could help me describe this. I was thinking that a power supply like this would work:


    If anybody has any suggestions regarding this I would be glad. I am essentially looking to power the circuit from a wall plug. Im pretty sure I need an AC/DC power supply that I can easily wire to the Arduino.

  • List item

Here is the arduino code from the sparksfun tutorial. I think I could probably adapt this for this application.

/******************************************************************************
Mux_Analog_Input
SparkFun Multiplexer Analog Input Example
Jim Lindblom @ SparkFun Electronics
August 15, 2016
https://github.com/sparkfun/74HC4051_8-Channel_Mux_Breakout

This sketch demonstrates how to use the SparkFun Multiplexer
Breakout - 8 Channel (74HC4051) to read eight, separate
analog inputs, using just a single ADC channel.

Hardware Hookup:
Mux Breakout ----------- Arduino
     S0 ------------------- 2
     S1 ------------------- 3
     S2 ------------------- 4
     Z -------------------- A0
    VCC ------------------- 5V
    GND ------------------- GND
    (VEE should be connected to GND)

The multiplexers independent I/O (Y0-Y7) can each be wired
up to a potentiometer or any other analog signal-producing
component.

Development environment specifics:
Arduino 1.6.9
SparkFun Multiplexer Breakout - 8-Channel(74HC4051) v10
(https://www.sparkfun.com/products/13906)
******************************************************************************/
/////////////////////
// Pin Definitions //
/////////////////////
const int selectPins[3] = {2, 3, 4}; // S0~2, S1~3, S2~4
const int zOutput = 5; 
const int zInput = A0; // Connect common (Z) to A0 (analog input)

void setup() 
{
  Serial.begin(9600); // Initialize the serial port
  // Set up the select pins as outputs:
  for (int i=0; i<3; i++)
  {
    pinMode(selectPins[i], OUTPUT);
    digitalWrite(selectPins[i], HIGH);
  }
  pinMode(zInput, INPUT); // Set up Z as an input

  // Print the header:
  Serial.println("Y0\tY1\tY2\tY3\tY4\tY5\tY6\tY7");
  Serial.println("---\t---\t---\t---\t---\t---\t---\t---");
}

void loop() 
{
  // Loop through all eight pins.
  for (byte pin=0; pin<=7; pin++)
  {
    selectMuxPin(pin); // Select one at a time
    int inputValue = analogRead(A0); // and read Z
    Serial.print(String(inputValue) + "\t");
  }
  Serial.println();
  delay(1000);
}

// The selectMuxPin function sets the S0, S1, and S2 pins
// accordingly, given a pin from 0-7.
void selectMuxPin(byte pin)
{
  for (int i=0; i<3; i++)
  {
    if (pin & (1<<i))
      digitalWrite(selectPins[i], HIGH);
    else
      digitalWrite(selectPins[i], LOW);
  }
}

and the webpage: Multiplexer Breakout Hookup Guide - SparkFun Learn

Conclusion
Thank you for your advice. I look forward to your correspondence.

Not really relevant to your question, but I'll ask anyway because It's very interesting. Is this an artificial mock elephant garlic you are using for something like an interactive art piece?

Thanks for asking, Yes its artificial, that was a big challenge. I developed the artifact from a real specimen.

And yes one could say it is interactive art. I originally put the question in that thread. I thought I could garner more response in the project guidance thread.

Way cool! I love it.

A couple of points.

The 74HC4051 multiplexer has 8 inputs. If you use a 74HC4067 instead, you can have 16 inputs per module.

To drive 64 LEDs, you wire them in a matrix and use a MAX7219 to drive them. Easiest using a matrix kit and wire your LEDs instead of the matrix supplied.

Hi,
Thank you for your advice. I would like to try this approach. From what i am seeing it looks like a matrix of LED is like a display. I need to light up LED sequins that would be all in different places. Would that be okay?


This was what im seeing as a matrix kit.
I need something that will allow me to set LEDs like this:

I gave an Aliexpress link for a single matrix kit module, but that vendor is out of stock. Here is a current link:

You buy the un-assembled module, do not mount the socket headers for the LED matrix itself, but solder the matrix that you have wired of your own LEDs to the connections where those headers would go.

Of course you have to figure out all the connections. :grin:

Hi,
I have some uncertainty regarding having LED respond to a state of the sensors. For the MAX7219 dot matrix module microcontroller module suggestions it seems that this module is best used to display text and patterns. How could I use this module to control a bunch of led. I am trying to get a specific LED to turn on when a specific sensor communicates a certain condition. Do you think this would be difficult to program with this module?

The MAX7219 can individually control any LED in a matrix, so you wire your LEDs in matrix form to match. They don't have to be on any sort of ordered array, of course, and you do not even need more than 1 LED for the basic wiring to work. Think of having a seven segment LED display, and turning just one segment on or off. (The MAX7219 will control one of those, too).

Maybe this tutorial will help. https://www.instructables.com/How-to-Build-8x8-BIG-LED-Matrix-MAX7219-LED-10mm/

Thanks for the tip. I wonder if you know how I could approach the other side. For example :
image
This seems very do-able, I get this. I dont know how I would concert this input with the LED matrix. Hopefully this question is clear. To restate how could I make an led turn on when when of the phtoresistors is exposed to light. I posted a chart that I would use to make sort of a binary signal from the Voltage divider, but I cant find a tutorial on how to link that with the matrix driver. Writing that code from scratch/modifying something would be hard for me but i am up to learn. Do you have any tips or hints to this end?

BTW that BIG LED matrix tutorial was totes helpful. I wonder should I just like go ahead and buy that PCB. I mean a i def dont need 10 and lead time would prob. be too long. I guess I can just use the unassembled module above ^. But still im like how do i get it to talk to the CdS sensors...

Well, if that PCB mounts the LEDs in the exact form you want, then go ahead. If you want a different arrangement, then I advise buying the board I cited and arrange your LEDs as you need and wire them to it in the form of a matrix.

That is where coding comes in. You write code to read the individual LDRs and process the levels to make decisions as to whether a corresponding LED should light, then those bits of data are arranged in a set of 8 "byte" variables (8 bits to each byte) which are then written to the MAX7219.

You just have to write the code to do each of these functions and test each step in the process.

Two things about wiring LDRs to the input multiplexers. Connect LDRs to ground, not Vcc. You need a pull-up resistor to 5 V but you do not need a pull-up resistor on each LDR, just one on the common terminal of the multiplexer which connects to the analog input.

Use a Nano, not a UNO.

Hi,
I put together a wiring diagram in paint interpreting what I think you said regarding the LDR wiring. I look forward to your thoughts!

The diagram is incorrect. Connect Z directly to the analog input, and connect the pullup resistor between 5V and the analog input.


like this?

Yes.

Also on the other side of this topic I have been reading throgugh the arduino playground shpiel on MAX72xx and i think this schematic will be relevant when wiring up individual LED. Would you agree/ any tips?

Le thanks

Yes, I’d say bookkeeping will be important…

Each individual LED will be wired to one of the 64 crosspoints of the matrix, no matter where it ends up physically.

Obvsly, I hope, if you have a number of LEDs near each other, their cathodes might share a common wire to the row they share, fewer wires to home plate that way.

The matrix diagram you posted already has a good name for every lamp, use those to keep track of what is where and what to illuminate.

But I write mostly because you have under-specified (been vague or unclear) about the kinds of patterns and responses you are hoping to achieve from the LDR inputs. Are there to be eventual 64 sensors? Or as many sensors as lamps? Are groups of LEDs or chase patterns being invoked?

BTW no need for there to be an LED at every position, in case that isn’t also obvious.

Tell us as much as you can without having to kill us for having done; this will inform the advices you receive on how the code might be structured.

Software is your friend, a little care and some details can be hidden so you can speak about the action/reaction in a higher order manner once the pesky details of reading the sensors and running the multiplexers, both of which should be completed and error free first, have been taken care of.

HTH

a7