School project Arduino Uno

Hello guys,

For my school project were making a interactive blok puzzel. When the user put the blok in the box, the light in the blok goes on and when it is outside the box it goes off. Now all the electricity connection is all working only the coding needs to be done. This is what we have in our code in the arduino:

int LED1 = 13;

int LED2 = 12;

int LED3 = 11;

void setup() {

// put your setup code here, to run once:

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);


void loop() {

// put your main code here, to run repeatedly:

digitalWrite(LED1, HIGH);

digitalWrite(LED2, HIGH);

digitalWrite(LED3, HIGH);


Now the only thing that needs to be done is when the user disconnect the led, then a random led between led needs to be shut down permanently. Until all of the leds are off. In this way we are trying te represent Alzheimer. Where the longer the illness is going the more lights in your brain are going out, until there is nothing left.

I believe a schematic will be necessary to make sense of your description.

So maybe if you provide a complete diagram of your wiring, we can make some suggestions?

I am just a starter at this, hope this will be usefull for you.

Hey, I am new to this Arduino, hope this diagram will make things clear for you

Your diagram does not show what this: "when the user disconnect the led, " means.
Is there a switch? Does the user tell the Arduino to turn off the LED? Does the user physically unsolder the LED leads? Are the LEDs in sockets with keyways so they will always be connected properly?

there are three fields where the three LEDs are lit. If the user covers one field with a square cardboard with an LED attached to the bottom, then it will also light up. When the cardboard is removed, its LED should go out and another LED on one of the fields too.

Am I guess right?

No there is no switch. In the prototype it's a jigsaw puzzle this is how it is supposed to look like a big puzzle from 5 x 5 bloks. How ever this is to much work for us to make, so the teachers said a proof of concept is enough, if we can show the functionality of our application.

The concept of our puzzle to represent the illness Alzheimer. The longer the person is suffering from Alzheimer the more braincells are going to die out, until there is nothing left. With our puzzle we are trying to represent that, by adding a image on top of the blok. When ever the user is putting a blok in the box a light goes on. How ever this puzzle needs to be unsolveble by each time a light randomly goes off. To represent the problem of Alzheimer.

Your circuit diagram shows no resistors in series with the LEDs, where are these supposed to be?

None I have placee no resistors. I am not really experienced with this. It is just that the teachers wanteded a physical application. From students that are following a visuel/ graphic design study :upside_down_face:

This is NOT how Alzheimers works! A person dies when the disease destroys the part of the brain managing the autonomic functions such as breathing and heat beat.

You would need some resistors for protecting your LED to not burn out and also to limit the current of the Arduino.

It sounds like you are trying to do two task with a single pin:

First, to power the LED.

Second to detect is a blok is inserted or not. I assume you need to detect if a blok is inserted in order to select a LED to randomly be switched off in the next step.

Using the same pin for both in and output functionality is difficult. It sounds like you might want to try using a dedicated input PIN for each LED to detect if a LED is inserted?

Which is most improbable in the case of Alzheimer's.

Looks elegant, but you have failed to explain so far how you propose to detect the presence of a block, and confusing us with whether or not there are supposed to be LEDs in vacant slots.

You need to realise that a LED requires a current limiting resistor in series. Did you know that? If you do not include this, you risk damage to both the LED and the Arduino. Generally a 220 ohm resistor will be appropriate. I am also assuming you are using white LEDs though that is not critical.

No, it turns out to be dead easy! :sunglasses: You can detect the presence of a LED with no other switches. You need to also include a 10k resistor in parallel with the LED in the block. It does not matter whether you choose to put the 220 ohm series resistor in the block or in the connection to the Arduino pin, the latter is perhaps safer.

Now to detect the presence or absence of the LED, your code sets the pinMode of the corresponding Arduino pin to INPUT_PULLUP and reads the pin - if a LED is present it will read LOW, of no LED is present it will read HIGH.

Shorting 10k resistor is good if not LED installed in box itself.
waiting for TO

I am afraid I cannot for the life of me understand that comment. :crazy_face:

Keep the LED wiring simple. Use 5V LEDs. They have the resistor included in the LED. They usually consume about 10mA so you can connect then directly to the arduino output pins. nqaynt is correct. use separate pins to detect inputs. Its just easier assuming you have enoughpins.

to simplify the schematic you can use addressable LEDs. this take only 1 pin on arduino, but 25 sensing pins can provide only Arduino Mega 2560.

So kolaha, you are pointing out the possibility of two LEDs per "slot". Yes, they would require separate pins and series resistors.

Since if there is only the LED in the box, you only require 1 pin anyway, there is no real benefit.

Also , you cannot chain addressable LEDs in removable boxes! :astonished:

yes. I have not seen the schematic from the topic stater and am wondering how it could be.
I saw a picture with boxes, but I do not understand how it should be a "puzzle" and "unsolvable"